Discover Packages
github.com/ClavinJune/httperr
package
module
Version:
v1.0.0
Opens a new window with list of versions in this module.
Published: May 31, 2021
License: GPL-3.0
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
httperr
Helper error for wrapping golang error with HTTP Status Code and stacktrace
Expand ▾
Collapse ▴
Documentation
¶
From creates new error from defined statusCode
if statusCode doesn't have any status text
statusCode changed to http.StatusInternalServerError
New wraps err with defined statusCode and message
Wrap wraps err with custom message
Wrap's result inherit statusCode from err if err equals *Error
type Error struct {
Err error
}
Error implements built in error with status code, caller, and message attribute
it is recommended to create Error from the provided method instead of creating
right from the struct to fill the caller.
Error returns error message with caller
StatusCode returns e.statusCode
Unwrap enables errors.As and errors.Is
Source Files
¶
Click to show internal directories.
Click to hide internal directories.