Make invoker error non fatal
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
parent
681f40ad75
commit
68cfff17e5
@ -27,6 +27,26 @@ func New(retCode uint8, message string) ActorError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Newf creates a new non-fatal error
|
||||||
|
func Newf(retCode uint8, format string, args ...interface{}) ActorError {
|
||||||
|
if retCode == 0 {
|
||||||
|
return &actorError{
|
||||||
|
fatal: true,
|
||||||
|
retCode: 0,
|
||||||
|
|
||||||
|
msg: "tried creating an error and setting RetCode to 0",
|
||||||
|
frame: xerrors.Caller(1),
|
||||||
|
err: fmt.Errorf(format, args...),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &actorError{
|
||||||
|
retCode: retCode,
|
||||||
|
|
||||||
|
msg: fmt.Sprintf(format, args...),
|
||||||
|
frame: xerrors.Caller(1),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Wrap extens chain of errors with a message
|
// Wrap extens chain of errors with a message
|
||||||
func Wrap(err ActorError, message string) ActorError {
|
func Wrap(err ActorError, message string) ActorError {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -35,10 +35,10 @@ func (inv *invoker) Invoke(act *types.Actor, vmctx *VMContext, method uint64, pa
|
|||||||
|
|
||||||
code, ok := inv.builtInCode[act.Code]
|
code, ok := inv.builtInCode[act.Code]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, aerrors.Escalate(fmt.Errorf("no code for actor %s", act.Code), "")
|
return nil, aerrors.Newf(255, "no code for actor %s", act.Code)
|
||||||
}
|
}
|
||||||
if method >= uint64(len(code)) || code[method] == nil {
|
if method >= uint64(len(code)) || code[method] == nil {
|
||||||
return nil, aerrors.Escalate(fmt.Errorf("no method %d on actor", method), "")
|
return nil, aerrors.Newf(255, "no method %d on actor", method)
|
||||||
}
|
}
|
||||||
return code[method](act, vmctx, params)
|
return code[method](act, vmctx, params)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user