Skip to content

Commit

Permalink
Add NewHTTPError
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed May 7, 2023
1 parent 45bebbc commit aec7f27
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func WrapHTTPError(code int, err error) HTTPError {
return wrappedHTTPError{code, err}
}

// NewHTTPError creates a new HTTPError with the given status code and message.
func NewHTTPError(code int, str string) HTTPError {
return wrappedHTTPError{code, errors.New(str)}
}

// OverrideHTTPError overrides the HTTP status code of the given error. If the
// error is not of type HTTPError, it is wrapped with the given status code. If
// it is, the error is unwrapped and wrapped with the new status code.
Expand Down

0 comments on commit aec7f27

Please sign in to comment.