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
import (
"errors"
)
var ErrBadGateway error = BadGatewayWrap(errors.New("Bad Gateway"))
type BadGateway interface {
ServerError
BadGateway()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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