From aec7f274358d64f822419b98a207cb3f6b9c1530 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Sun, 7 May 2023 00:37:49 -0700 Subject: [PATCH] Add NewHTTPError --- error.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/error.go b/error.go index 9819b4f..2fd8a9e 100644 --- a/error.go +++ b/error.go @@ -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.