From e513884a5a142d3c21e01a7c18b1d50a8f3845e2 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 23 Jul 2019 15:04:45 +0200 Subject: [PATCH] Cleanup lint License: MIT Signed-off-by: Jakub Sztandera --- chain/actors/aerrors/error.go | 3 +-- chain/actors/aerrors/wrap.go | 14 +++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/chain/actors/aerrors/error.go b/chain/actors/aerrors/error.go index d78c6d9ad..ca545e366 100644 --- a/chain/actors/aerrors/error.go +++ b/chain/actors/aerrors/error.go @@ -12,9 +12,8 @@ func IsFatal(err ActorError) bool { func RetCode(err ActorError) uint8 { if err == nil { return 0 - } else { - return err.RetCode() } + return err.RetCode() } type internalActorError interface { diff --git a/chain/actors/aerrors/wrap.go b/chain/actors/aerrors/wrap.go index 04638d2f8..0703f76bc 100644 --- a/chain/actors/aerrors/wrap.go +++ b/chain/actors/aerrors/wrap.go @@ -6,7 +6,18 @@ import ( "golang.org/x/xerrors" ) +// New creates a new non-fatal error func New(retCode uint8, message string) 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: err, + } + } return &actorError{ retCode: retCode, @@ -15,6 +26,7 @@ func New(retCode uint8, message string) ActorError { } } +// Wrap extens chain of errors with a message func Wrap(err ActorError, message string) ActorError { if err == nil { return nil @@ -29,7 +41,7 @@ func Wrap(err ActorError, message string) ActorError { } } -// Wrap extens chain of errors with +// Wrapf extens chain of errors with a message func Wrapf(err ActorError, format string, args ...interface{}) ActorError { if err == nil { return nil