added package-level globals for each error. in case the developer does not want to set their own error message or wrap another error.

master
Charles Iliya Krempeaux 2023-02-16 11:36:53 -08:00
parent b59535530a
commit bbaaf21002
40 changed files with 240 additions and 0 deletions

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrBadGateway error = BadGatewayWrap(errors.New("Bad Gateway"))
type BadGateway interface { type BadGateway interface {
ServerError ServerError
BadGateway() BadGateway()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrBadRequest = BadRequestWrap(errors.New("Bad Request"))
type BadRequest interface { type BadRequest interface {
ClientError ClientError
BadRequest() BadRequest()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrConflict = ConflictWrap(errors.New("Conflict"))
type Conflict interface { type Conflict interface {
ClientError ClientError
Conflict() Conflict()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrExpectationFailed error = ExpectationFailedWrap(errors.New("Expectation Failed"))
type ExpectationFailed interface { type ExpectationFailed interface {
ClientError ClientError
ExpectationFailed() ExpectationFailed()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrFailedDependency error = FailedDependencyWrap(errors.New("Failed Dependency"))
type FailedDependency interface { type FailedDependency interface {
ClientError ClientError
FailedDependency() FailedDependency()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrForbidden error = ForbiddenWrap(errors.New("Forbidden"))
type Forbidden interface { type Forbidden interface {
ClientError ClientError
Forbidden() Forbidden()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrGatewayTimeout error = GatewayTimeoutWrap(errors.New("Gateway Timeout"))
type GatewayTimeout interface { type GatewayTimeout interface {
ServerError ServerError
GatewayTimeout() GatewayTimeout()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrGone error = GoneWrap(errors.New("Gone"))
type Gone interface { type Gone interface {
ClientError() ClientError()
Gone() Gone()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrHTTPVersionNotSupported error = HTTPVersionNotSupportedWrap(errors.New("HTTP Version Not Supported"))
type HTTPVersionNotSupported interface { type HTTPVersionNotSupported interface {
ServerError ServerError
HTTPVersionNotSupported() HTTPVersionNotSupported()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrInsufficientStorage error = InsufficientStorageWrap(errors.New("Insufficient Storage"))
type InsufficientStorage interface { type InsufficientStorage interface {
ServerError ServerError
InsufficientStorage() InsufficientStorage()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrInternalServerError error = InternalServerErrorWrap(errors.New("Internal Server Error"))
type InternalServerError interface { type InternalServerError interface {
ServerError ServerError
InternalServerError() InternalServerError()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrLengthRequired error = LengthRequiredWrap(errors.New("Length Required"))
type LengthRequired interface { type LengthRequired interface {
ClientError ClientError
LengthRequired() LengthRequired()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrLocked error = LockedWrap(errors.New("Locked"))
type Locked interface { type Locked interface {
ClientError ClientError
Locked() Locked()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrLoopDetected error = LoopDetectedWrap(errors.New("Loop Detected"))
type LoopDetected interface { type LoopDetected interface {
ServerError ServerError
LoopDetected() LoopDetected()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrMethodNotAllowed error = MethodNotAllowedWrap(errors.New("Method Not Allowed"))
type MethodNotAllowed interface { type MethodNotAllowed interface {
ClientError ClientError
MethodNotAllowed() MethodNotAllowed()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrNetworkAuthenticationRequired error = NetworkAuthenticationRequiredWrap(errors.New("Network Authentication Required"))
type NetworkAuthenticationRequired interface { type NetworkAuthenticationRequired interface {
ServerError ServerError
NetworkAuthenticationRequired() NetworkAuthenticationRequired()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrNotAcceptable error = NotAcceptableWrap(errors.New("Not Acceptable"))
type NotAcceptable interface { type NotAcceptable interface {
ClientError ClientError
NotAcceptable() NotAcceptable()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrNotExtended error = NotExtendedWrap(errors.New("Not Extended"))
type NotExtended interface { type NotExtended interface {
ServerError ServerError
NotExtended() NotExtended()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrNotFound error = NotFoundWrap(errors.New("Not Found"))
type NotFound interface { type NotFound interface {
ClientError ClientError
NotFound () NotFound ()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrNotImplemented error = NotImplementedWrap(errors.New("Not Implemented"))
type NotImplemented interface { type NotImplemented interface {
ServerError ServerError
NotImplemented() NotImplemented()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrPayloadTooLarge error = PayloadTooLargeWrap(errors.New("Payload Too Large"))
type PayloadTooLarge interface { type PayloadTooLarge interface {
ClientError ClientError
PayloadTooLarge() PayloadTooLarge()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrPaymentRequired error = PaymentRequiredWrap(errors.New("Payment Required"))
type PaymentRequired interface { type PaymentRequired interface {
ClientError ClientError
PaymentRequired() PaymentRequired()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrPreconditionFailed error = PreconditionFailedWrap(errors.New("Precondition Failed"))
type PreconditionFailed interface { type PreconditionFailed interface {
ClientError ClientError
PreconditionFailed() PreconditionFailed()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrPreconditionRequired error = PreconditionRequiredWrap(errors.New("Precondition Required"))
type PreconditionRequired interface { type PreconditionRequired interface {
ClientError ClientError
PreconditionRequired() PreconditionRequired()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrProxyAuthRequired error = ProxyAuthRequiredWrap(errors.New("Proxy Auth Required"))
type ProxyAuthRequired interface { type ProxyAuthRequired interface {
ClientError ClientError
ProxyAuthRequired() ProxyAuthRequired()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrRequestedRangeNotSatisfiable error = RequestedRangeNotSatisfiableWrap(errors.New("Requested Range Not Satisfiable"))
type RequestedRangeNotSatisfiable interface { type RequestedRangeNotSatisfiable interface {
ClientError ClientError
RequestedRangeNotSatisfiable() RequestedRangeNotSatisfiable()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrRequestEntityTooLarge error = RequestEntityTooLargeWrap(errors.New("Request Entity Too Large"))
type RequestEntityTooLarge interface { type RequestEntityTooLarge interface {
ClientError ClientError
RequestEntityTooLarge() RequestEntityTooLarge()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrRequestHeaderFieldsTooLarge error = RequestHeaderFieldsTooLargeWrap(errors.New("RequestHeaderFieldsTooLarge"))
type RequestHeaderFieldsTooLarge interface { type RequestHeaderFieldsTooLarge interface {
error error
Err() error Err() error

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrRequestTimeout error = RequestTimeoutWrap(errors.New("Request Timeout"))
type RequestTimeout interface { type RequestTimeout interface {
error error
Err() error Err() error

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrRequestURITooLong error = RequestURITooLongWrap(errors.New("Request URI Too Long"))
type RequestURITooLong interface { type RequestURITooLong interface {
error error
Err() error Err() error

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrServiceUnavailable error = ServiceUnavailableWrap(errors.New("Service Unavailable"))
type ServiceUnavailable interface { type ServiceUnavailable interface {
ServerError ServerError
ServiceUnavailable() ServiceUnavailable()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrTeapot error = TeapotWrap(errors.New("I'm a teapot"))
type Teapot interface { type Teapot interface {
ClientError ClientError
Teapot() Teapot()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrTooManyRequests error = TooManyRequestsWrap(errors.New("Too Many Requests"))
type TooManyRequests interface { type TooManyRequests interface {
ClientError ClientError
TooManyRequests() TooManyRequests()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrUnauthorized error = UnauthorizedWrap(errors.New("Unauthorized"))
type Unauthorized interface { type Unauthorized interface {
ClientError ClientError
Unauthorized() Unauthorized()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrUnavailableForLegalReasons error = UnavailableForLegalReasonsWrap(errors.New("Unavailable For Legal Reasons"))
type UnavailableForLegalReasons interface { type UnavailableForLegalReasons interface {
ClientError ClientError
UnavailableForLegalReasons() UnavailableForLegalReasons()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrUnprocessableEntity error = UnprocessableEntityWrap(errors.New("Unprocessable Entity"))
type UnprocessableEntity interface { type UnprocessableEntity interface {
ClientError ClientError
UnprocessableEntity() UnprocessableEntity()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrUnsupportedMediaType error = UnsupportedMediaTypeWrap(errors.New("Unsupported Media Type"))
type UnsupportedMediaType interface { type UnsupportedMediaType interface {
ClientError ClientError
UnsupportedMediaType() UnsupportedMediaType()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrUpgradeRequired error = UpgradeRequiredWrap(errors.New("Upgrade Required"))
type UpgradeRequired interface { type UpgradeRequired interface {
ClientError ClientError
UpgradeRequired() UpgradeRequired()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrURITooLong error = URITooLongWrap(errors.New("URI Too Long"))
type URITooLong interface { type URITooLong interface {
ClientError ClientError
URITooLong() URITooLong()

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
import (
"errors"
)
var ErrVariantAlsoNegotiates error = VariantAlsoNegotiatesWrap(errors.New("Variant Also Negotiates"))
type VariantAlsoNegotiates interface { type VariantAlsoNegotiates interface {
ServerError ServerError
VariantAlsoNegotiates() VariantAlsoNegotiates()