Skip to content

Commit

Permalink
changes error return type
Browse files Browse the repository at this point in the history
  • Loading branch information
BoogVAr committed Sep 26, 2023
1 parent a69b790 commit eb8e655
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions pkg/errors/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,35 @@ func (e Error) Cause() error {
return errors.Cause(e)
}

func New(msg string) error {
func New(msg string) Error {
return Error{errorType: NoType, originalError: errors.New(msg)}
}

func Newf(msg string, args ...interface{}) error {
func Newf(msg string, args ...interface{}) Error {
return Error{errorType: NoType, originalError: errors.New(fmt.Sprintf(msg, args...))}
}

func NewWithCode(code ErrorCode, msg string) error {
func NewWithCode(code ErrorCode, msg string) Error {
return Error{code: code, errorType: NoType, originalError: errors.New(msg)}
}

func NewfWithCode(code ErrorCode, msg string, args ...interface{}) error {
func NewfWithCode(code ErrorCode, msg string, args ...interface{}) Error {
return Error{code: code, errorType: NoType, originalError: errors.New(fmt.Sprintf(msg, args...))}
}

func Wrap(err error, msg string) error {
func Wrap(err error, msg string) Error {
return Wrapf(err, msg)
}

func WrapWithCode(code ErrorCode, err error, msg string) error {
func WrapWithCode(code ErrorCode, err error, msg string) Error {
return WrapfWithCode(code, err, msg)
}

func Cause(err error) error {
return errors.Cause(err)
}

func Wrapf(err error, msg string, args ...interface{}) error {
func Wrapf(err error, msg string, args ...interface{}) Error {
wrappedError := errors.Wrapf(err, msg, args...)
if customErr, ok := err.(Error); ok {
return Error{
Expand All @@ -101,7 +101,7 @@ func Wrapf(err error, msg string, args ...interface{}) error {
return Error{errorType: NoType, originalError: wrappedError}
}

func WrapfWithCode(code ErrorCode, err error, msg string, args ...interface{}) error {
func WrapfWithCode(code ErrorCode, err error, msg string, args ...interface{}) Error {
wrappedError := errors.Wrapf(err, msg, args...)
if customErr, ok := err.(Error); ok {
return Error{
Expand Down
16 changes: 8 additions & 8 deletions pkg/errors/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,41 @@ func (t ErrorType) String() string {
}
}

func (t ErrorType) New(msg string) error {
func (t ErrorType) New(msg string) Error {
return Error{errorType: t, originalError: errors.New(msg)}
}

func (t ErrorType) Newf(msg string, args ...interface{}) error {
func (t ErrorType) Newf(msg string, args ...interface{}) Error {
err := fmt.Errorf(msg, args...)

return Error{errorType: t, originalError: err}
}

func (t ErrorType) NewWithCode(code ErrorCode, msg string) error {
func (t ErrorType) NewWithCode(code ErrorCode, msg string) Error {
return Error{code: code, errorType: t, originalError: errors.New(msg)}
}

func (t ErrorType) NewfWithCode(code ErrorCode, msg string, args ...interface{}) error {
func (t ErrorType) NewfWithCode(code ErrorCode, msg string, args ...interface{}) Error {
err := fmt.Errorf(msg, args...)

return Error{code: code, errorType: t, originalError: err}
}

func (t ErrorType) Wrap(err error, msg string) error {
func (t ErrorType) Wrap(err error, msg string) Error {
return t.Wrapf(err, msg)
}

func (t ErrorType) Wrapf(err error, msg string, args ...interface{}) error {
func (t ErrorType) Wrapf(err error, msg string, args ...interface{}) Error {
newErr := errors.Wrapf(err, msg, args...)

return Error{errorType: t, originalError: newErr}
}

func (t ErrorType) WrapWithCode(code ErrorCode, err error, msg string) error {
func (t ErrorType) WrapWithCode(code ErrorCode, err error, msg string) Error {
return t.WrapfWithCode(code, err, msg)
}

func (t ErrorType) WrapfWithCode(code ErrorCode, err error, msg string, args ...interface{}) error {
func (t ErrorType) WrapfWithCode(code ErrorCode, err error, msg string, args ...interface{}) Error {
newErr := errors.Wrapf(err, msg, args...)

return Error{code: code, errorType: t, originalError: newErr}
Expand Down

0 comments on commit eb8e655

Please sign in to comment.