Skip to content

Commit

Permalink
Merge pull request #12 from infiniteloopcloud/11-weird-helpers
Browse files Browse the repository at this point in the history
Add NewOrElse
  • Loading branch information
PumpkinSeed committed Apr 12, 2023
2 parents 5ae468c + 3f11809 commit 6fe7cec
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions weird/weird.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ func New(msg string, err error, statusCode int) error {
}
}

func NewOrElse(msg string, err error, statusCode int) error {
if _, ok := err.(Error); ok {
return err
}
return New(msg, err, statusCode)
}

// Error satisfy the error interface and format the error
func (e Error) Error() string {
if e.InnerError != nil {
Expand Down

0 comments on commit 6fe7cec

Please sign in to comment.