httperrors

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 3 Imported by: 31

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBadRequest

func IsBadRequest(httperr *HTTPErrorResponse) bool

IsBadRequest returns true if the error is a bad request error

func IsConflict

func IsConflict(httperr *HTTPErrorResponse) bool

IsConflict returns true if the error is a conflict error

func IsForbidden

func IsForbidden(httperr *HTTPErrorResponse) bool

IsForbidden returns true if the error is a forbidden error

func IsInternalServerError

func IsInternalServerError(httperr *HTTPErrorResponse) bool

IsInternalServerError returns true if the error is an internal server error

func IsNotFound

func IsNotFound(httperr *HTTPErrorResponse) bool

IsNotFound returns true if the error is a not found error

func IsUnauthorized

func IsUnauthorized(httperr *HTTPErrorResponse) bool

IsUnauthorized returns true if the error is an unauthorized error

func IsUnprocessableEntity

func IsUnprocessableEntity(httperr *HTTPErrorResponse) bool

IsUnprocessableEntity returns true if the error is an unprocessable entity error

Types

type HTTPErrorResponse

type HTTPErrorResponse struct {
	StatusCode int    `json:"statuscode" description:"http status code"`
	Message    string `json:"message" description:"error message"`
}

HTTPErrorResponse is returned in case of functional errors.

func BadRequest

func BadRequest(err error) *HTTPErrorResponse

BadRequest creates a new bad request error with a given error message. Convenience Method.

func Conflict

func Conflict(err error) *HTTPErrorResponse

Conflict creates a new conflict error with a given error message. Convenience Method.

func Forbidden

func Forbidden(err error) *HTTPErrorResponse

Forbidden creates a new forbidden response with a given error message. Convenience Method.

func FromDefaultResponse

func FromDefaultResponse(statusCode *int32, message *string, err error) *HTTPErrorResponse

FromDefaultResponse creates an error response from a client default http error response. Returns an unconventional error if response could not be unmarshaled.

func InternalServerError

func InternalServerError(err error) *HTTPErrorResponse

InternalServerError creates a new internal server error with a given error message. Convenience Method.

func NewHTTPError

func NewHTTPError(code int, err error) *HTTPErrorResponse

NewHTTPError creates a new http error.

func NotFound

func NotFound(err error) *HTTPErrorResponse

NotFound creates a new notfound error with a given error message. Convenience Method.

func Unauthorized

func Unauthorized(err error) *HTTPErrorResponse

Unauthorized creates a new unauthorized response with a given error message. Convenience Method.

func UnconventionalError

func UnconventionalError(err error) *HTTPErrorResponse

UnconventionalError creates a new error with a given error message for a response that did not follow the internal error convention. Convenience Method.

func UnknownError

func UnknownError(err error) *HTTPErrorResponse

UnknownError creates a new internal server error with a given error message. Convenience Method. Is actually also just an internal server error.

func UnprocessableEntity

func UnprocessableEntity(err error) *HTTPErrorResponse

UnprocessableEntity creates a new unprocessable entity request error with a given error message. Convenience Method.

func (*HTTPErrorResponse) Error added in v0.3.2

func (h *HTTPErrorResponse) Error() string

func (*HTTPErrorResponse) MarshalText added in v0.6.6

func (h *HTTPErrorResponse) MarshalText() ([]byte, error)

func (*HTTPErrorResponse) UnmarshalText added in v0.6.5

func (h *HTTPErrorResponse) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL