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) {
|
||||
item, err := stackitem.ToJSONWithTypes(ne.Item)
|
||||
if err != nil {
|
||||
item = []byte(`"error: recursive reference"`)
|
||||
item = []byte(fmt.Sprintf(`"error: %v"`, err))
|
||||
}
|
||||
return json.Marshal(¬ificationEventAux{
|
||||
ScriptHash: ne.ScriptHash,
|
||||
|
@ -191,12 +191,11 @@ type executionAux struct {
|
|||
|
||||
// MarshalJSON implements implements json.Marshaler interface.
|
||||
func (e Execution) MarshalJSON() ([]byte, error) {
|
||||
var errRecursive = []byte(`"error: recursive reference"`)
|
||||
arr := make([]json.RawMessage, len(e.Stack))
|
||||
for i := range arr {
|
||||
data, err := stackitem.ToJSONWithTypes(e.Stack[i])
|
||||
if err != nil {
|
||||
data = errRecursive
|
||||
data = []byte(fmt.Sprintf(`"error: %v"`, err))
|
||||
}
|
||||
arr[i] = data
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ func (r Invoke) MarshalJSON() ([]byte, error) {
|
|||
for j := range iteratorValues {
|
||||
value[j], err = stackitem.ToJSONWithTypes(iteratorValues[j])
|
||||
if err != nil {
|
||||
st = []byte(`"error: recursive reference"`)
|
||||
st = []byte(fmt.Sprintf(`"error: %v"`, err))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ func (r Invoke) MarshalJSON() ([]byte, error) {
|
|||
} else {
|
||||
data, err = stackitem.ToJSONWithTypes(r.Stack[i])
|
||||
if err != nil {
|
||||
st = []byte(`"error: recursive reference"`)
|
||||
st = []byte(fmt.Sprintf(`"error: %v"`, err))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue