From 1378d24feeb09abe0c5b61a026aa30979b83af94 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 7 Jun 2024 10:59:54 +0800 Subject: [PATCH] add exception message to the incorrect storeitem --- .../ApplicationLogs/Store/LogStorageStore.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Plugins/ApplicationLogs/Store/LogStorageStore.cs b/src/Plugins/ApplicationLogs/Store/LogStorageStore.cs index b8f817238c..105da2c786 100644 --- a/src/Plugins/ApplicationLogs/Store/LogStorageStore.cs +++ b/src/Plugins/ApplicationLogs/Store/LogStorageStore.cs @@ -15,6 +15,7 @@ using Neo.SmartContract; using Neo.VM; using Neo.VM.Types; +using System.Text; namespace Neo.Plugins.ApplicationLogs.Store { @@ -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; }