errors

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGeneralBadRequest                    = New("general error, Bad Request")
	ErrGeneralUnauthorized                  = New("general error, Unauthorized")
	ErrGeneralPaymentRequired               = New("general error, Payment Required")
	ErrGeneralForbidden                     = New("general error, Forbidden")
	ErrGeneralNotFound                      = New("general error, Not Found")
	ErrGeneralMethodNotAllowed              = New("general error, Method Not Allowed")
	ErrGeneralNotAcceptable                 = New("general error, Not Acceptable")
	ErrGeneralProxyAuthRequired             = New("general error, Proxy Authentication Required")
	ErrGeneralRequestTimeout                = New("general error, Request Timeout")
	ErrGeneralConflict                      = New("general error, Conflict")
	ErrGeneralGone                          = New("general error, Gone")
	ErrGeneralLengthRequired                = New("general error, Length Required")
	ErrGeneralPreconditionFailed            = New("general error, Precondition Failed")
	ErrGeneralRequestEntityTooLarge         = New("general error, Request Entity Too Large")
	ErrGeneralRequestURITooLong             = New("general error, Request URI Too Long")
	ErrGeneralUnsupportedMediaType          = New("general error, Unsupported Media Type")
	ErrGeneralRequestedRangeNotSatisfiable  = New("general error, Requested Range Not Satisfiable")
	ErrGeneralExpectationFailed             = New("general error, Expectation Failed")
	ErrGeneralTeapot                        = New("general error, I'm a teapot")
	ErrGeneralMisdirectedRequest            = New("general error, Misdirected Request")
	ErrGeneralUnprocessableEntity           = New("general error, Unprocessable Entity")
	ErrGeneralLocked                        = New("general error, Locked")
	ErrGeneralFailedDependency              = New("general error, Failed Dependency")
	ErrGeneralTooEarly                      = New("general error, Too Early")
	ErrGeneralUpgradeRequired               = New("general error, Upgrade Required")
	ErrGeneralPreconditionRequired          = New("general error, Precondition Required")
	ErrGeneralTooManyRequests               = New("general error, Too Many Requests")
	ErrGeneralRequestHeaderFieldsTooLarge   = New("general error, Request Header Fields Too Large")
	ErrGeneralUnavailableForLegalReasons    = New("general error, Unavailable For Legal Reasons")
	ErrGeneralInternalServerError           = New("general error, Internal Server Error")
	ErrGeneralNotImplemented                = New("general error, Not Implemented")
	ErrGeneralBadGateway                    = New("general error, Bad Gateway")
	ErrGeneralServiceUnavailable            = New("general error, Service Unavailable")
	ErrGeneralGatewayTimeout                = New("general error, Gateway Timeout")
	ErrGeneralHTTPVersionNotSupported       = New("general error, HTTP Version Not Supported")
	ErrGeneralVariantAlsoNegotiates         = New("general error, Variant Also Negotiates")
	ErrGeneralInsufficientStorage           = New("general error, Insufficient Storage")
	ErrGeneralLoopDetected                  = New("general error, Loop Detected")
	ErrGeneralNotExtended                   = New("general error, Not Extended")
	ErrGeneralNetworkAuthenticationRequired = New("general error, Network Authentication Required")
)
View Source
var ErrorMap = map[int]error{
	http.StatusBadRequest:                    ErrGeneralBadRequest,
	http.StatusUnauthorized:                  ErrGeneralUnauthorized,
	http.StatusPaymentRequired:               ErrGeneralPaymentRequired,
	http.StatusForbidden:                     ErrGeneralForbidden,
	http.StatusNotFound:                      ErrGeneralNotFound,
	http.StatusMethodNotAllowed:              ErrGeneralMethodNotAllowed,
	http.StatusNotAcceptable:                 ErrGeneralNotAcceptable,
	http.StatusProxyAuthRequired:             ErrGeneralProxyAuthRequired,
	http.StatusRequestTimeout:                ErrGeneralRequestTimeout,
	http.StatusConflict:                      ErrGeneralConflict,
	http.StatusGone:                          ErrGeneralGone,
	http.StatusLengthRequired:                ErrGeneralLengthRequired,
	http.StatusPreconditionFailed:            ErrGeneralPreconditionFailed,
	http.StatusRequestEntityTooLarge:         ErrGeneralRequestEntityTooLarge,
	http.StatusRequestURITooLong:             ErrGeneralRequestURITooLong,
	http.StatusUnsupportedMediaType:          ErrGeneralUnsupportedMediaType,
	http.StatusRequestedRangeNotSatisfiable:  ErrGeneralRequestedRangeNotSatisfiable,
	http.StatusExpectationFailed:             ErrGeneralExpectationFailed,
	http.StatusTeapot:                        ErrGeneralTeapot,
	http.StatusMisdirectedRequest:            ErrGeneralMisdirectedRequest,
	http.StatusUnprocessableEntity:           ErrGeneralUnprocessableEntity,
	http.StatusLocked:                        ErrGeneralLocked,
	http.StatusFailedDependency:              ErrGeneralFailedDependency,
	http.StatusTooEarly:                      ErrGeneralTooEarly,
	http.StatusUpgradeRequired:               ErrGeneralUpgradeRequired,
	http.StatusPreconditionRequired:          ErrGeneralPreconditionRequired,
	http.StatusTooManyRequests:               ErrGeneralTooManyRequests,
	http.StatusRequestHeaderFieldsTooLarge:   ErrGeneralRequestHeaderFieldsTooLarge,
	http.StatusUnavailableForLegalReasons:    ErrGeneralUnavailableForLegalReasons,
	http.StatusInternalServerError:           ErrGeneralInternalServerError,
	http.StatusNotImplemented:                ErrGeneralNotImplemented,
	http.StatusBadGateway:                    ErrGeneralBadGateway,
	http.StatusServiceUnavailable:            ErrGeneralServiceUnavailable,
	http.StatusGatewayTimeout:                ErrGeneralGatewayTimeout,
	http.StatusHTTPVersionNotSupported:       ErrGeneralHTTPVersionNotSupported,
	http.StatusVariantAlsoNegotiates:         ErrGeneralVariantAlsoNegotiates,
	http.StatusInsufficientStorage:           ErrGeneralInsufficientStorage,
	http.StatusLoopDetected:                  ErrGeneralLoopDetected,
	http.StatusNotExtended:                   ErrGeneralNotExtended,
	http.StatusNetworkAuthenticationRequired: ErrGeneralNetworkAuthenticationRequired,
}

Error map to associate status codes with error variables

Functions

func ParseErr

func ParseErr(err error) (int, error)

Types

type Error

type Error struct {
	Data            interface{} `json:"data"`
	Message         string      `json:"message"`
	InternalMessage string      `json:"-"`
}

func New

func New(message string) *Error

func (*Error) Error

func (e *Error) Error() string

Error implements error.

func (*Error) WithData

func (e *Error) WithData(data interface{}) *Error

func (*Error) WithInternalMessage

func (e *Error) WithInternalMessage(internalMessage string) *Error

Jump to

Keyboard shortcuts

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