forked from TrueCloudLab/neoneo-go
state/result: save/return real JSONization errors
Don't hide/obfuscate real problems.
This commit is contained in:
parent
e62a766058
commit
0cd9cd0c80
2 changed files with 4 additions and 5 deletions
|
@ -101,7 +101,7 @@ type notificationEventAux struct {
|
||||||
func (ne NotificationEvent) MarshalJSON() ([]byte, error) {
|
func (ne NotificationEvent) MarshalJSON() ([]byte, error) {
|
||||||
item, err := stackitem.ToJSONWithTypes(ne.Item)
|
item, err := stackitem.ToJSONWithTypes(ne.Item)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
item = []byte(`"error: recursive reference"`)
|
item = []byte(fmt.Sprintf(`"error: %v"`, err))
|
||||||
}
|
}
|
||||||
return json.Marshal(¬ificationEventAux{
|
return json.Marshal(¬ificationEventAux{
|
||||||
ScriptHash: ne.ScriptHash,
|
ScriptHash: ne.ScriptHash,
|
||||||
|
@ -191,12 +191,11 @@ type executionAux struct {
|
||||||
|
|
||||||
// MarshalJSON implements implements json.Marshaler interface.
|
// MarshalJSON implements implements json.Marshaler interface.
|
||||||
func (e Execution) MarshalJSON() ([]byte, error) {
|
func (e Execution) MarshalJSON() ([]byte, error) {
|
||||||
var errRecursive = []byte(`"error: recursive reference"`)
|
|
||||||
arr := make([]json.RawMessage, len(e.Stack))
|
arr := make([]json.RawMessage, len(e.Stack))
|
||||||
for i := range arr {
|
for i := range arr {
|
||||||
data, err := stackitem.ToJSONWithTypes(e.Stack[i])
|
data, err := stackitem.ToJSONWithTypes(e.Stack[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
data = errRecursive
|
data = []byte(fmt.Sprintf(`"error: %v"`, err))
|
||||||
}
|
}
|
||||||
arr[i] = data
|
arr[i] = data
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ func (r Invoke) MarshalJSON() ([]byte, error) {
|
||||||
for j := range iteratorValues {
|
for j := range iteratorValues {
|
||||||
value[j], err = stackitem.ToJSONWithTypes(iteratorValues[j])
|
value[j], err = stackitem.ToJSONWithTypes(iteratorValues[j])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
st = []byte(`"error: recursive reference"`)
|
st = []byte(fmt.Sprintf(`"error: %v"`, err))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ func (r Invoke) MarshalJSON() ([]byte, error) {
|
||||||
} else {
|
} else {
|
||||||
data, err = stackitem.ToJSONWithTypes(r.Stack[i])
|
data, err = stackitem.ToJSONWithTypes(r.Stack[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
st = []byte(`"error: recursive reference"`)
|
st = []byte(fmt.Sprintf(`"error: %v"`, err))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue