Documentation ¶
Overview ¶
Package httperror is the reusable http error collection
Index ¶
- Variables
- func BadRequestWith(err error) error
- func ConflictWith(err error) error
- func ForbiddenWith(err error) error
- func GRPC(err error) error
- func GoneWith(err error) error
- func InternalServerErrorWith(err error) error
- func Merge(err, other error) error
- func MethodNotAllowedWith(err error) error
- func NewError(status int, code string, message string) error
- func NewHTTPError(status int, code string) error
- func NotFoundWith(err error) error
- func RequestTimeoutWith(err error) error
- func UnauthorizedWith(err error) error
- type CodeFunc
- type Error
- type Func
- type StatusFunc
Constants ¶
This section is empty.
Variables ¶
var ( BadRequest = newPreDefinedHTTPError(http.StatusBadRequest) Forbidden = newPreDefinedHTTPError(http.StatusForbidden) NotFound = newPreDefinedHTTPError(http.StatusNotFound) MethodNotAllowed = newPreDefinedHTTPError(http.StatusMethodNotAllowed) RequestTimeout = newPreDefinedHTTPError(http.StatusRequestTimeout) Conflict = newPreDefinedHTTPError(http.StatusConflict) Gone = newPreDefinedHTTPError(http.StatusGone) InternalServerError = newPreDefinedHTTPError(http.StatusInternalServerError) NotImplemented = newPreDefinedHTTPError(http.StatusNotImplemented) )
Pre-defined errors
Functions ¶
func BadRequestWith ¶
BadRequestWith merges error with bad request
func InternalServerErrorWith ¶
InternalServerErrorWith merges error with internal server error
func Merge ¶
Merge an error with other error if one or both errors are Error type, result will be an Error if none is Error, result will be native go's error
func MethodNotAllowedWith ¶
MethodNotAllowedWith merges error with method not allowed
func NewHTTPError ¶
NewHTTPError is the helper function for create http error
func RequestTimeoutWith ¶
RequestTimeoutWith merges error with request timeout
func UnauthorizedWith ¶
UnauthorizedWith merges error with unauthorized
Types ¶
type CodeFunc ¶
CodeFunc is the error creator function pre-defined code
func NewWithCode ¶
NewWithCode is the helper function for create CodeFunc
type Error ¶
type Error struct { Status int `json:"status"` // http status code Code string `json:"code"` // error code Message string `json:"message"` // error message }
Error is the httperror's Error
type StatusFunc ¶
StatusFunc is the error creator function pre-defined status
func NewWithStatus ¶
func NewWithStatus(status int) StatusFunc
NewWithStatus is the helper function for create StatusFunc