feat: support typed errors over RPC
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user