state: Ignore decode errors in compute-state --html

This commit is contained in:
Łukasz Magiera 2024-02-18 00:14:55 +01:00
parent bcc1d09c84
commit 9ec2a65d9b

View File

@ -1388,15 +1388,19 @@ func JsonParams(code cid.Cid, method abi.MethodNum, params []byte) (string, erro
p, err := stmgr.GetParamType(ar, code, method) // todo use api for correct actor registry p, err := stmgr.GetParamType(ar, code, method) // todo use api for correct actor registry
if err != nil { if err != nil {
return "", err return fmt.Sprintf("raw:%x; DECODE ERR: %s", params, err.Error()), nil
} }
if err := p.UnmarshalCBOR(bytes.NewReader(params)); err != nil { if err := p.UnmarshalCBOR(bytes.NewReader(params)); err != nil {
return "", err return fmt.Sprintf("raw:%x; DECODE cbor ERR: %s", params, err.Error()), nil
} }
b, err := json.MarshalIndent(p, "", " ") b, err := json.MarshalIndent(p, "", " ")
return string(b), err if err != nil {
return "", err
}
return string(b), nil
} }
func JsonReturn(code cid.Cid, method abi.MethodNum, ret []byte) (string, error) { func JsonReturn(code cid.Cid, method abi.MethodNum, ret []byte) (string, error) {
@ -1407,7 +1411,7 @@ func JsonReturn(code cid.Cid, method abi.MethodNum, ret []byte) (string, error)
re := reflect.New(methodMeta.Ret.Elem()) re := reflect.New(methodMeta.Ret.Elem())
p := re.Interface().(cbg.CBORUnmarshaler) p := re.Interface().(cbg.CBORUnmarshaler)
if err := p.UnmarshalCBOR(bytes.NewReader(ret)); err != nil { if err := p.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
return "", err return fmt.Sprintf("raw:%x; DECODE ERR: %s", ret, err.Error()), nil
} }
b, err := json.MarshalIndent(p, "", " ") b, err := json.MarshalIndent(p, "", " ")