added .Unwrap()error methods, and some error checking

master
Charles Iliya Krempeaux 2023-02-15 22:24:28 -08:00
parent ed36b20373
commit b59535530a
41 changed files with 174 additions and 0 deletions

View File

@ -5,6 +5,8 @@ type BadGateway interface {
BadGateway() BadGateway()
} }
var _ BadGateway = internalBadGateway{}
type internalBadGateway struct { type internalBadGateway struct {
err error err error
} }
@ -30,3 +32,7 @@ func (internalBadGateway) ServerError() {
func (internalBadGateway) BadGateway() { func (internalBadGateway) BadGateway() {
// Nothing here. // Nothing here.
} }
func (receiver internalBadGateway) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalBadRequest) ClientError() {
func (internalBadRequest) BadRequest() { func (internalBadRequest) BadRequest() {
// Nothing here. // Nothing here.
} }
func (receiver internalBadRequest) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalConflict) ClientError() {
func (internalConflict) Conflict() { func (internalConflict) Conflict() {
// Nothing here. // Nothing here.
} }
func (receiver internalConflict) Unwrap() error {
return receiver.err
}

View File

@ -3,4 +3,5 @@ package errhttp
type Error interface { type Error interface {
error error
Err() error Err() error
Unwrap() error
} }

View File

@ -30,3 +30,7 @@ func (internalExpectationFailed) ClientError() {
func (internalExpectationFailed) ExpectationFailed() { func (internalExpectationFailed) ExpectationFailed() {
// Nothing here. // Nothing here.
} }
func (receiver internalExpectationFailed) Unwrap() error {
return receiver.err
}

View File

@ -31,3 +31,6 @@ func (internalFailedDependency) FailedDependency() {
// Nothing here. // Nothing here.
} }
func (receiver internalFailedDependency) Unwrap() error {
return receiver.err
}

View File

@ -31,3 +31,6 @@ func (internalForbidden) Forbidden() {
// Nothing here. // Nothing here.
} }
func (receiver internalForbidden) Unwrap() error {
return receiver.err
}

View File

@ -5,6 +5,8 @@ type GatewayTimeout interface {
GatewayTimeout() GatewayTimeout()
} }
var _ GatewayTimeout = internalGatewayTimeout{}
type internalGatewayTimeout struct { type internalGatewayTimeout struct {
err error err error
} }
@ -30,3 +32,7 @@ func (internalGatewayTimeout) ServerError() {
func (internalGatewayTimeout) GatewayTimeout() { func (internalGatewayTimeout) GatewayTimeout() {
// Nothing here. // Nothing here.
} }
func (receiver internalGatewayTimeout) Unwrap() error {
return receiver.err
}

View File

@ -31,3 +31,6 @@ func (internalGone) Gone() {
// Nothing here. // Nothing here.
} }
func (receiver internalGone) Unwrap() error {
return receiver.err
}

View File

@ -5,6 +5,8 @@ type HTTPVersionNotSupported interface {
HTTPVersionNotSupported() HTTPVersionNotSupported()
} }
var _ HTTPVersionNotSupported = internalHTTPVersionNotSupported{}
type internalHTTPVersionNotSupported struct { type internalHTTPVersionNotSupported struct {
err error err error
} }
@ -30,3 +32,7 @@ func (internalHTTPVersionNotSupported) ServerError() {
func (internalHTTPVersionNotSupported) HTTPVersionNotSupported() { func (internalHTTPVersionNotSupported) HTTPVersionNotSupported() {
// Nothing here. // Nothing here.
} }
func (receiver internalHTTPVersionNotSupported) Unwrap() error {
return receiver.err
}

View File

@ -5,6 +5,8 @@ type InsufficientStorage interface {
InsufficientStorage() InsufficientStorage()
} }
var _ InsufficientStorage = internalInsufficientStorage{}
type internalInsufficientStorage struct { type internalInsufficientStorage struct {
err error err error
} }
@ -30,3 +32,7 @@ func (internalInsufficientStorage) ServerError() {
func (internalInsufficientStorage) InsufficientStorage() { func (internalInsufficientStorage) InsufficientStorage() {
// Nothing here. // Nothing here.
} }
func (receiver internalInsufficientStorage) Unwrap() error {
return receiver.err
}

View File

@ -5,6 +5,8 @@ type InternalServerError interface {
InternalServerError() InternalServerError()
} }
var _ InternalServerError = internalInternalServerError{}
type internalInternalServerError struct { type internalInternalServerError struct {
err error err error
} }
@ -30,3 +32,7 @@ func (internalInternalServerError) ServerError() {
func (internalInternalServerError) InternalServerError() { func (internalInternalServerError) InternalServerError() {
// Nothing here. // Nothing here.
} }
func (receiver internalInternalServerError) Unwrap() error {
return receiver.err
}

View File

@ -31,3 +31,6 @@ func (internalLengthRequired) LengthRequired() {
// Nothing here. // Nothing here.
} }
func (receiver internalLengthRequired) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalLocked) ClientError() {
func (internalLocked) Locked() { func (internalLocked) Locked() {
// Nothing here. // Nothing here.
} }
func (receiver internalLocked) Unwrap() error {
return receiver.err
}

View File

@ -5,6 +5,8 @@ type LoopDetected interface {
LoopDetected() LoopDetected()
} }
var _ LoopDetected = internalLoopDetected{}
type internalLoopDetected struct { type internalLoopDetected struct {
err error err error
} }
@ -30,3 +32,7 @@ func (internalLoopDetected) ServerError() {
func (internalLoopDetected) LoopDetected() { func (internalLoopDetected) LoopDetected() {
// Nothing here. // Nothing here.
} }
func (receiver internalLoopDetected) Unwrap() error {
return receiver.err
}

View File

@ -31,3 +31,6 @@ func (internalMethodNotAllowed) MethodNotAllowed() {
// Nothing here. // Nothing here.
} }
func (receiver internalMethodNotAllowed) Unwrap() error {
return receiver.err
}

View File

@ -5,6 +5,8 @@ type NetworkAuthenticationRequired interface {
NetworkAuthenticationRequired() NetworkAuthenticationRequired()
} }
var _ NetworkAuthenticationRequired = internalNetworkAuthenticationRequired{}
type internalNetworkAuthenticationRequired struct { type internalNetworkAuthenticationRequired struct {
err error err error
} }
@ -30,3 +32,7 @@ func (internalNetworkAuthenticationRequired) ServerError() {
func (internalNetworkAuthenticationRequired) NetworkAuthenticationRequired() { func (internalNetworkAuthenticationRequired) NetworkAuthenticationRequired() {
// Nothing here. // Nothing here.
} }
func (receiver internalNetworkAuthenticationRequired) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalNotAcceptable) ClientError() {
func (internalNotAcceptable) NotAcceptable() { func (internalNotAcceptable) NotAcceptable() {
// Nothing here. // Nothing here.
} }
func (receiver internalNotAcceptable) Unwrap() error {
return receiver.err
}

View File

@ -5,6 +5,8 @@ type NotExtended interface {
NotExtended() NotExtended()
} }
var _ NotExtended = internalNotExtended{}
type internalNotExtended struct { type internalNotExtended struct {
err error err error
} }
@ -30,3 +32,7 @@ func (internalNotExtended) ServerError() {
func (internalNotExtended) NotExtended() { func (internalNotExtended) NotExtended() {
// Nothing here. // Nothing here.
} }
func (receiver internalNotExtended) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalNotFound ) ClientError() {
func (internalNotFound ) NotFound() { func (internalNotFound ) NotFound() {
// Nothing here. // Nothing here.
} }
func (receiver internalNotFound) Unwrap() error {
return receiver.err
}

View File

@ -5,6 +5,8 @@ type NotImplemented interface {
NotImplemented() NotImplemented()
} }
var _ NotImplemented = internalNotImplemented{}
type internalNotImplemented struct { type internalNotImplemented struct {
err error err error
} }
@ -30,3 +32,7 @@ func (internalNotImplemented) ServerError() {
func (internalNotImplemented) NotImplemented() { func (internalNotImplemented) NotImplemented() {
// Nothing here. // Nothing here.
} }
func (receiver internalNotImplemented) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalPayloadTooLarge) ClientError() {
func (internalPayloadTooLarge) PayloadTooLarge() { func (internalPayloadTooLarge) PayloadTooLarge() {
// Nothing here. // Nothing here.
} }
func (receiver internalPayloadTooLarge) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalPaymentRequired) ClientError() {
func (internalPaymentRequired) PaymentRequired() { func (internalPaymentRequired) PaymentRequired() {
// Nothing here. // Nothing here.
} }
func (receiver internalPaymentRequired) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalPreconditionFailed) ClientError() {
func (internalPreconditionFailed) PreconditionFailed() { func (internalPreconditionFailed) PreconditionFailed() {
// Nothing here. // Nothing here.
} }
func (receiver internalPreconditionFailed) Unwrap() error {
return receiver.err
}

View File

@ -31,3 +31,6 @@ func (internalPreconditionRequired) PreconditionRequired() {
// Nothing here. // Nothing here.
} }
func (receiver internalPreconditionRequired) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalProxyAuthRequired) ClientError() {
func (internalProxyAuthRequired) ProxyAuthRequired() { func (internalProxyAuthRequired) ProxyAuthRequired() {
// Nothing here. // Nothing here.
} }
func (receiver internalProxyAuthRequired) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalRequestedRangeNotSatisfiable) ClientError() {
func (internalRequestedRangeNotSatisfiable) RequestedRangeNotSatisfiable() { func (internalRequestedRangeNotSatisfiable) RequestedRangeNotSatisfiable() {
// Nothing here. // Nothing here.
} }
func (receiver internalRequestedRangeNotSatisfiable) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalRequestEntityTooLarge) ClientError() {
func (internalRequestEntityTooLarge) RequestEntityTooLarge() { func (internalRequestEntityTooLarge) RequestEntityTooLarge() {
// Nothing here. // Nothing here.
} }
func (receiver internalRequestEntityTooLarge) Unwrap() error {
return receiver.err
}

View File

@ -31,3 +31,7 @@ func (internalRequestHeaderFieldsTooLarge) ClientError() {
func (internalRequestHeaderFieldsTooLarge) RequestHeaderFieldsTooLarge() { func (internalRequestHeaderFieldsTooLarge) RequestHeaderFieldsTooLarge() {
// Nothing here. // Nothing here.
} }
func (receiver internalRequestHeaderFieldsTooLarge) Unwrap() error {
return receiver.err
}

View File

@ -31,3 +31,7 @@ func (internalRequestTimeout) ClientError() {
func (internalRequestTimeout) RequestTimeout() { func (internalRequestTimeout) RequestTimeout() {
// Nothing here. // Nothing here.
} }
func (receiver internalRequestTimeout) Unwrap() error {
return receiver.err
}

View File

@ -31,3 +31,7 @@ func (internalRequestURITooLong) ClientError() {
func (internalRequestURITooLong) RequestURITooLong() { func (internalRequestURITooLong) RequestURITooLong() {
// Nothing here. // Nothing here.
} }
func (receiver internalRequestURITooLong) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalServiceUnavailable) ServerError() {
func (internalServiceUnavailable) ServiceUnavailable() { func (internalServiceUnavailable) ServiceUnavailable() {
// Nothing here. // Nothing here.
} }
func (receiver internalServiceUnavailable) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalTeapot) ClientError() {
func (internalTeapot) Teapot() { func (internalTeapot) Teapot() {
// Nothing here. // Nothing here.
} }
func (receiver internalTeapot) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalTooManyRequests) ClientError() {
func (internalTooManyRequests) TooManyRequests() { func (internalTooManyRequests) TooManyRequests() {
// Nothing here. // Nothing here.
} }
func (receiver internalTooManyRequests) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalUnauthorized) ClientError() {
func (internalUnauthorized) Unauthorized() { func (internalUnauthorized) Unauthorized() {
// Nothing here. // Nothing here.
} }
func (receiver internalUnauthorized) Unwrap() error {
return receiver.err
}

View File

@ -31,3 +31,6 @@ func (internalUnavailableForLegalReasons) UnavailableForLegalReasons() {
// Nothing here. // Nothing here.
} }
func (receiver internalUnavailableForLegalReasons) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalUnprocessableEntity) ClientError() {
func (internalUnprocessableEntity) UnprocessableEntity() { func (internalUnprocessableEntity) UnprocessableEntity() {
// Nothing here. // Nothing here.
} }
func (receiver internalUnprocessableEntity) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalUnsupportedMediaType) ClientError() {
func (internalUnsupportedMediaType) UnsupportedMediaType() { func (internalUnsupportedMediaType) UnsupportedMediaType() {
// Nothing here. // Nothing here.
} }
func (receiver internalUnsupportedMediaType) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalUpgradeRequired) ClientError() {
func (internalUpgradeRequired) UpgradeRequired() { func (internalUpgradeRequired) UpgradeRequired() {
// Nothing here. // Nothing here.
} }
func (receiver internalUpgradeRequired) Unwrap() error {
return receiver.err
}

View File

@ -30,3 +30,7 @@ func (internalURITooLong) ClientError() {
func (internalURITooLong) URITooLong() { func (internalURITooLong) URITooLong() {
// Nothing here. // Nothing here.
} }
func (receiver internalURITooLong) Unwrap() error {
return receiver.err
}

View File

@ -5,6 +5,8 @@ type VariantAlsoNegotiates interface {
VariantAlsoNegotiates() VariantAlsoNegotiates()
} }
var _ VariantAlsoNegotiates = internalVariantAlsoNegotiates{}
type internalVariantAlsoNegotiates struct { type internalVariantAlsoNegotiates struct {
err error err error
} }
@ -30,3 +32,7 @@ func (internalVariantAlsoNegotiates) ServerError() {
func (internalVariantAlsoNegotiates) VariantAlsoNegotiates() { func (internalVariantAlsoNegotiates) VariantAlsoNegotiates() {
// Nothing here. // Nothing here.
} }
func (receiver internalVariantAlsoNegotiates) Unwrap() error {
return receiver.err
}