feat: support typed errors over RPC

This commit is contained in:
Aayush
2022-09-22 11:44:19 -04:00
parent 37be57610c
commit 93f94d4ee9
16 changed files with 127 additions and 24 deletions
+5 -1
View File
@@ -290,6 +290,10 @@ func gasEstimateGasLimit(
if err != nil {
return -1, xerrors.Errorf("CallWithGas failed: %w", err)
}
if res.MsgRct.ExitCode == exitcode.SysErrOutOfGas {
return -1, api.ErrOutOfGas{}
}
if res.MsgRct.ExitCode != exitcode.Ok {
return -1, xerrors.Errorf("message execution failed: exit %s, reason: %s", res.MsgRct.ExitCode, res.Error)
}
@@ -356,7 +360,7 @@ func (m *GasModule) GasEstimateMessageGas(ctx context.Context, msg *types.Messag
if msg.GasLimit == 0 {
gasLimit, err := m.GasEstimateGasLimit(ctx, msg, types.EmptyTSK)
if err != nil {
return nil, xerrors.Errorf("estimating gas used: %w", err)
return nil, err
}
msg.GasLimit = int64(float64(gasLimit) * m.Mpool.GetConfig().GasLimitOverestimation)
}
+6 -1
View File
@@ -482,7 +482,12 @@ func (m *StateModule) StateLookupID(ctx context.Context, addr address.Address, t
return address.Undef, xerrors.Errorf("loading tipset %s: %w", tsk, err)
}
return m.StateManager.LookupID(ctx, addr, ts)
ret, err := m.StateManager.LookupID(ctx, addr, ts)
if err != nil && xerrors.Is(err, types.ErrActorNotFound) {
return address.Undef, api.ErrActorNotFound{}
}
return ret, err
}
func (a *StateAPI) StateLookupRobustAddress(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) {