goerror

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 3 Imported by: 4

README

goerror

Core error interface in Go

Install
go get github.com/prongbang/gorerror
How to use
  • Unauthorized error
err := goerror.NewUnauthorized()

Documentation

Index

Constants

View Source
const (
	// Informational
	CodeContinue           = "INF000"
	CodeSwitchingProtocols = "INF001"
	CodeProcessing         = "INF002"
	CodeEarlyHints         = "INF003"

	// Successful
	CodeOK                          = "SUC000"
	CodeCreated                     = "SUC001"
	CodeAccepted                    = "SUC002"
	CodeNonAuthoritativeInformation = "SUC003"
	CodeNoContent                   = "SUC004"
	CodeResetContent                = "SUC005"
	CodePartialContent              = "SUC006"
	CodeMultiStatus                 = "SUC007"
	CodeAlreadyReported             = "SUC008"
	CodeIMUsed                      = "SUC009"

	// Redirection
	CodeMultipleChoices   = "RED000"
	CodeMovedPermanently  = "RED001"
	CodeFound             = "RED002"
	CodeSeeOther          = "RED003"
	CodeNotModified       = "RED004"
	CodeUseProxy          = "RED005"
	CodeTemporaryRedirect = "RED007"
	CodePermanentRedirect = "RED008"

	// Client error
	CodeBadRequest                   = "CLE000"
	CodeUnauthorized                 = "CLE001"
	CodePaymentRequired              = "CLE002"
	CodeForbidden                    = "CLE003"
	CodeNotFound                     = "CLE004"
	CodeMethodNotAllowed             = "CLE005"
	CodeNotAcceptable                = "CLE006"
	CodeProxyAuthRequired            = "CLE007"
	CodeRequestTimeout               = "CLE008"
	CodeConflict                     = "CLE009"
	CodeGone                         = "CLE010"
	CodeLengthRequired               = "CLE011"
	CodePreconditionFailed           = "CLE012"
	CodeRequestEntityTooLarge        = "CLE013"
	CodeRequestURITooLong            = "CLE014"
	CodeUnsupportedMediaType         = "CLE015"
	CodeRequestedRangeNotSatisfiable = "CLE016"
	CodeExpectationFailed            = "CLE017"
	CodeTeapot                       = "CLE018"
	CodeMisdirectedRequest           = "CLE019"
	CodeUnprocessableEntity          = "CLE020"
	CodeLocked                       = "CLE021"
	CodeFailedDependency             = "CLE022"
	CodeTooEarly                     = "CLE023"
	CodeUpgradeRequired              = "CLE024"
	CodePreconditionRequired         = "CLE025"
	CodeTooManyRequests              = "CLE026"
	CodeRequestHeaderFieldsTooLarge  = "CLE027"
	CodeUnavailableForLegalReasons   = "CLE028"

	// Server error
	CodeInternalServerError           = "SVR000"
	CodeNotImplemented                = "SVR001"
	CodeBadGateway                    = "SVR002"
	CodeServiceUnavailable            = "SVR003"
	CodeGatewayTimeout                = "SVR004"
	CodeHTTPVersionNotSupported       = "SVR005"
	CodeVariantAlsoNegotiates         = "SVR006"
	CodeInsufficientStorage           = "SVR007"
	CodeLoopDetected                  = "SVR008"
	CodeNotExtended                   = "SVR009"
	CodeNetworkAuthenticationRequired = "SVR010"
)

Variables

This section is empty.

Functions

func NewAccepted

func NewAccepted() error

func NewAlreadyReported

func NewAlreadyReported() error

func NewBadGateway

func NewBadGateway() error

func NewBadRequest

func NewBadRequest(message ...string) error

func NewConflict

func NewConflict() error

func NewContinue

func NewContinue() error

func NewCreated

func NewCreated(data any) error

func NewEarlyHints

func NewEarlyHints() error

func NewError added in v1.0.1

func NewError(body Body) error

func NewExpectationFailed

func NewExpectationFailed() error

func NewFailedDependency

func NewFailedDependency() error

func NewForbidden

func NewForbidden() error

func NewFound

func NewFound() error

func NewGatewayTimeout

func NewGatewayTimeout() error

func NewGone

func NewGone() error

func NewHTTPVersionNotSupported

func NewHTTPVersionNotSupported() error

func NewIMUsed

func NewIMUsed() error

func NewInsufficientStorage

func NewInsufficientStorage() error

func NewInternalServerError

func NewInternalServerError() error

func NewLengthRequired

func NewLengthRequired() error

func NewLocked

func NewLocked() error

func NewLoopDetected

func NewLoopDetected() error

func NewMethodNotAllowed

func NewMethodNotAllowed() error

func NewMisdirectedRequest

func NewMisdirectedRequest() error

func NewMovedPermanently

func NewMovedPermanently() error

func NewMultiStatus

func NewMultiStatus() error

func NewMultipleChoices

func NewMultipleChoices() error

func NewNetworkAuthenticationRequired

func NewNetworkAuthenticationRequired() error

func NewNoContent

func NewNoContent() error

func NewNonAuthoritativeInformation

func NewNonAuthoritativeInformation() error

func NewNotAcceptable

func NewNotAcceptable() error

func NewNotExtended

func NewNotExtended() error

func NewNotFound

func NewNotFound() error

func NewNotImplemented

func NewNotImplemented() error

func NewNotModified

func NewNotModified() error

func NewOK

func NewOK(data any) error

func NewPartialContent

func NewPartialContent() error

func NewPaymentRequired

func NewPaymentRequired() error

func NewPermanentRedirect

func NewPermanentRedirect() error

func NewPreconditionFailed

func NewPreconditionFailed() error

func NewPreconditionRequired

func NewPreconditionRequired() error

func NewProcessing

func NewProcessing() error

func NewProxyAuthRequired

func NewProxyAuthRequired() error

func NewRequestEntityTooLarge

func NewRequestEntityTooLarge() error

func NewRequestHeaderFieldsTooLarge

func NewRequestHeaderFieldsTooLarge() error

func NewRequestTimeout

func NewRequestTimeout() error

func NewRequestURITooLong

func NewRequestURITooLong() error

func NewRequestedRangeNotSatisfiable

func NewRequestedRangeNotSatisfiable() error

func NewResetContent

func NewResetContent() error

func NewSeeOther

func NewSeeOther() error

func NewServiceUnavailable

func NewServiceUnavailable() error

func NewSwitchingProtocols

func NewSwitchingProtocols() error

func NewTeapot

func NewTeapot() error

func NewTemporaryRedirect

func NewTemporaryRedirect() error

func NewTooEarly

func NewTooEarly() error

func NewTooManyRequests

func NewTooManyRequests() error

func NewUnauthorized

func NewUnauthorized() error

func NewUnavailableForLegalReasons

func NewUnavailableForLegalReasons() error

func NewUnprocessableEntity

func NewUnprocessableEntity() error

func NewUnsupportedMediaType

func NewUnsupportedMediaType() error

func NewUpgradeRequired

func NewUpgradeRequired() error

func NewUseProxy

func NewUseProxy() error

func NewVariantAlsoNegotiates

func NewVariantAlsoNegotiates() error

func SetMessage

func SetMessage(err interface{}, message string)

Types

type Accepted

type Accepted struct {
	Body
}

func (*Accepted) Error

func (a *Accepted) Error() string

Error implements error.

type AlreadyReported

type AlreadyReported struct {
	Body
}

func (*AlreadyReported) Error

func (a *AlreadyReported) Error() string

Error implements error.

type BadGateway

type BadGateway struct {
	Body
}

func (*BadGateway) Error

func (a *BadGateway) Error() string

Error implements error.

type BadRequest

type BadRequest struct {
	Body
}

func (*BadRequest) Error

func (b *BadRequest) Error() string

Error implements error.

type Body

type Body struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data"`
}

func GetBody

func GetBody(err error) (Body, error)

type Conflict

type Conflict struct {
	Body
}

func (*Conflict) Error

func (c *Conflict) Error() string

Error implements error.

type Continue

type Continue struct {
	Body
}

func (*Continue) Error

func (c *Continue) Error() string

Error implements error.

type Created

type Created struct {
	Body
}

func (*Created) Error

func (c *Created) Error() string

Error implements error.

type EarlyHints

type EarlyHints struct {
	Body
}

func (*EarlyHints) Error

func (e *EarlyHints) Error() string

Error implements error.

type Error added in v1.0.1

type Error struct {
	Body
}

func (*Error) Error added in v1.0.1

func (e *Error) Error() string

type ExpectationFailed

type ExpectationFailed struct {
	Body
}

func (*ExpectationFailed) Error

func (a *ExpectationFailed) Error() string

Error implements error.

type FailedDependency

type FailedDependency struct {
	Body
}

func (*FailedDependency) Error

func (a *FailedDependency) Error() string

Error implements error.

type Forbidden

type Forbidden struct {
	Body
}

func (*Forbidden) Error

func (f *Forbidden) Error() string

Error implements error.

type Found

type Found struct {
	Body
}

func (*Found) Error

func (f *Found) Error() string

Error implements error.

type GatewayTimeout

type GatewayTimeout struct {
	Body
}

func (*GatewayTimeout) Error

func (a *GatewayTimeout) Error() string

Error implements error.

type Gone

type Gone struct {
	Body
}

func (*Gone) Error

func (a *Gone) Error() string

Error implements error.

type HTTPVersionNotSupported

type HTTPVersionNotSupported struct {
	Body
}

func (*HTTPVersionNotSupported) Error

func (a *HTTPVersionNotSupported) Error() string

Error implements error.

type IMUsed

type IMUsed struct {
	Body
}

func (*IMUsed) Error

func (i *IMUsed) Error() string

Error implements error.

type InsufficientStorage

type InsufficientStorage struct {
	Body
}

func (*InsufficientStorage) Error

func (a *InsufficientStorage) Error() string

Error implements error.

type InternalServerError

type InternalServerError struct {
	Body
}

func (*InternalServerError) Error

func (a *InternalServerError) Error() string

Error implements error.

type LengthRequired

type LengthRequired struct {
	Body
}

func (*LengthRequired) Error

func (a *LengthRequired) Error() string

Error implements error.

type Locked

type Locked struct {
	Body
}

func (*Locked) Error

func (a *Locked) Error() string

Error implements error.

type LoopDetected

type LoopDetected struct {
	Body
}

func (*LoopDetected) Error

func (a *LoopDetected) Error() string

Error implements error.

type MethodNotAllowed

type MethodNotAllowed struct {
	Body
}

func (*MethodNotAllowed) Error

func (m *MethodNotAllowed) Error() string

Error implements error.

type MisdirectedRequest

type MisdirectedRequest struct {
	Body
}

func (*MisdirectedRequest) Error

func (a *MisdirectedRequest) Error() string

Error implements error.

type MovedPermanently

type MovedPermanently struct {
	Body
}

func (*MovedPermanently) Error

func (m *MovedPermanently) Error() string

Error implements error.

type MultiStatus

type MultiStatus struct {
	Body
}

func (*MultiStatus) Error

func (m *MultiStatus) Error() string

Error implements error.

type MultipleChoices

type MultipleChoices struct {
	Body
}

func (*MultipleChoices) Error

func (m *MultipleChoices) Error() string

Error implements error.

type NetworkAuthenticationRequired

type NetworkAuthenticationRequired struct {
	Body
}

func (*NetworkAuthenticationRequired) Error

Error implements error.

type NoContent

type NoContent struct {
	Body
}

func (*NoContent) Error

func (n *NoContent) Error() string

Error implements error.

type NonAuthoritativeInformation

type NonAuthoritativeInformation struct {
	Body
}

func (*NonAuthoritativeInformation) Error

Error implements error.

type NotAcceptable

type NotAcceptable struct {
	Body
}

func (*NotAcceptable) Error

func (n *NotAcceptable) Error() string

Error implements error.

type NotExtended

type NotExtended struct {
	Body
}

func (*NotExtended) Error

func (a *NotExtended) Error() string

Error implements error.

type NotFound

type NotFound struct {
	Body
}

func (*NotFound) Error

func (t *NotFound) Error() string

Error implements error.

type NotImplemented

type NotImplemented struct {
	Body
}

func (*NotImplemented) Error

func (a *NotImplemented) Error() string

Error implements error.

type NotModified

type NotModified struct {
	Body
}

func (*NotModified) Error

func (n *NotModified) Error() string

Error implements error.

type OK

type OK struct {
	Body
}

func (*OK) Error

func (e *OK) Error() string

type PartialContent

type PartialContent struct {
	Body
}

func (*PartialContent) Error

func (p *PartialContent) Error() string

Error implements error.

type PaymentRequired

type PaymentRequired struct {
	Body
}

func (*PaymentRequired) Error

func (p *PaymentRequired) Error() string

Error implements error.

type PermanentRedirect

type PermanentRedirect struct {
	Body
}

func (*PermanentRedirect) Error

func (p *PermanentRedirect) Error() string

Error implements error.

type PreconditionFailed

type PreconditionFailed struct {
	Body
}

func (*PreconditionFailed) Error

func (a *PreconditionFailed) Error() string

Error implements error.

type PreconditionRequired

type PreconditionRequired struct {
	Body
}

func (*PreconditionRequired) Error

func (a *PreconditionRequired) Error() string

Error implements error.

type Processing

type Processing struct {
	Body
}

func (*Processing) Error

func (p *Processing) Error() string

Error implements error.

type ProxyAuthRequired

type ProxyAuthRequired struct {
	Body
}

func (*ProxyAuthRequired) Error

func (p *ProxyAuthRequired) Error() string

Error implements error.

type RequestEntityTooLarge

type RequestEntityTooLarge struct {
	Body
}

func (*RequestEntityTooLarge) Error

func (a *RequestEntityTooLarge) Error() string

Error implements error.

type RequestHeaderFieldsTooLarge

type RequestHeaderFieldsTooLarge struct {
	Body
}

func (*RequestHeaderFieldsTooLarge) Error

Error implements error.

type RequestTimeout

type RequestTimeout struct {
	Body
}

func (*RequestTimeout) Error

func (r *RequestTimeout) Error() string

Error implements error.

type RequestURITooLong

type RequestURITooLong struct {
	Body
}

func (*RequestURITooLong) Error

func (a *RequestURITooLong) Error() string

Error implements error.

type RequestedRangeNotSatisfiable

type RequestedRangeNotSatisfiable struct {
	Body
}

func (*RequestedRangeNotSatisfiable) Error

Error implements error.

type ResetContent

type ResetContent struct {
	Body
}

func (*ResetContent) Error

func (r *ResetContent) Error() string

Error implements error.

type SeeOther

type SeeOther struct {
	Body
}

func (*SeeOther) Error

func (s *SeeOther) Error() string

Error implements error.

type ServiceUnavailable

type ServiceUnavailable struct {
	Body
}

func (*ServiceUnavailable) Error

func (a *ServiceUnavailable) Error() string

Error implements error.

type SwitchingProtocols

type SwitchingProtocols struct {
	Body
}

func (*SwitchingProtocols) Error

func (s *SwitchingProtocols) Error() string

Error implements error.

type Teapot

type Teapot struct {
	Body
}

func (*Teapot) Error

func (a *Teapot) Error() string

Error implements error.

type TemporaryRedirect

type TemporaryRedirect struct {
	Body
}

func (*TemporaryRedirect) Error

func (t *TemporaryRedirect) Error() string

Error implements error.

type TooEarly

type TooEarly struct {
	Body
}

func (*TooEarly) Error

func (a *TooEarly) Error() string

Error implements error.

type TooManyRequests

type TooManyRequests struct {
	Body
}

func (*TooManyRequests) Error

func (a *TooManyRequests) Error() string

Error implements error.

type Unauthorized

type Unauthorized struct {
	Body
}

func (*Unauthorized) Error

func (e *Unauthorized) Error() string

type UnavailableForLegalReasons

type UnavailableForLegalReasons struct {
	Body
}

func (*UnavailableForLegalReasons) Error

Error implements error.

type UnprocessableEntity

type UnprocessableEntity struct {
	Body
}

func (*UnprocessableEntity) Error

func (a *UnprocessableEntity) Error() string

Error implements error.

type UnsupportedMediaType

type UnsupportedMediaType struct {
	Body
}

func (*UnsupportedMediaType) Error

func (a *UnsupportedMediaType) Error() string

Error implements error.

type UpgradeRequired

type UpgradeRequired struct {
	Body
}

func (*UpgradeRequired) Error

func (a *UpgradeRequired) Error() string

Error implements error.

type UseProxy

type UseProxy struct {
	Body
}

func (*UseProxy) Error

func (u *UseProxy) Error() string

Error implements error.

type VariantAlsoNegotiates

type VariantAlsoNegotiates struct {
	Body
}

func (*VariantAlsoNegotiates) Error

func (a *VariantAlsoNegotiates) Error() string

Error implements error.

Jump to

Keyboard shortcuts

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