Skip to content

Commit

Permalink
add exception message to the incorrect storeitem
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim8y committed Jun 7, 2024
1 parent c183732 commit 1378d24
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Plugins/ApplicationLogs/Store/LogStorageStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Neo.SmartContract;
using Neo.VM;
using Neo.VM.Types;
using System.Text;

namespace Neo.Plugins.ApplicationLogs.Store
{
Expand Down Expand Up @@ -159,9 +160,20 @@ public Guid PutStackItemState(StackItem stackItem)
{
_snapshot.Put(key, BinarySerializer.Serialize(stackItem, ExecutionEngineLimits.Default with { MaxItemSize = (uint)Settings.Default.MaxStackSize }));
}
catch // Ref. https://github.com/neo-project/neo/issues/3296
catch (NotSupportedException ex) // Ref. https://github.com/neo-project/neo/issues/3296
{
_snapshot.Put(key, BinarySerializer.Serialize(StackItem.Null, ExecutionEngineLimits.Default with { MaxItemSize = (uint)Settings.Default.MaxStackSize }));
var message = ex.Message.Length > 1024 ? string.Concat(ex.Message.AsSpan(0, 1021), "...") : ex.Message;
_snapshot.Put(key, Encoding.UTF8.GetBytes("Not Supported Exception: " + message));
}
catch (FormatException ex)
{
var message = ex.Message.Length > 1024 ? string.Concat(ex.Message.AsSpan(0, 1021), "...") : ex.Message;
_snapshot.Put(key, Encoding.UTF8.GetBytes("Format Exception: " + message));
}
catch (Exception ex)
{
var message = ex.Message.Length > 1024 ? string.Concat(ex.Message.AsSpan(0, 1021), "...") : ex.Message;
_snapshot.Put(key, Encoding.UTF8.GetBytes("Exception: " + message));
}
return id;
}
Expand Down

0 comments on commit 1378d24

Please sign in to comment.