Cleanup lint

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
Jakub Sztandera 2019-07-23 15:04:45 +02:00
parent 537ff23a63
commit e513884a5a
2 changed files with 14 additions and 3 deletions

View File

@ -12,9 +12,8 @@ func IsFatal(err ActorError) bool {
func RetCode(err ActorError) uint8 { func RetCode(err ActorError) uint8 {
if err == nil { if err == nil {
return 0 return 0
} else {
return err.RetCode()
} }
return err.RetCode()
} }
type internalActorError interface { type internalActorError interface {

View File

@ -6,7 +6,18 @@ import (
"golang.org/x/xerrors" "golang.org/x/xerrors"
) )
// New creates a new non-fatal error
func New(retCode uint8, message string) ActorError { 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{ return &actorError{
retCode: retCode, 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 { func Wrap(err ActorError, message string) ActorError {
if err == nil { if err == nil {
return 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 { func Wrapf(err ActorError, format string, args ...interface{}) ActorError {
if err == nil { if err == nil {
return nil return nil