added .Unwrap()error methods, and some error checking
parent
ed36b20373
commit
b59535530a
|
@ -5,6 +5,8 @@ type BadGateway interface {
|
|||
BadGateway()
|
||||
}
|
||||
|
||||
var _ BadGateway = internalBadGateway{}
|
||||
|
||||
type internalBadGateway struct {
|
||||
err error
|
||||
}
|
||||
|
@ -30,3 +32,7 @@ func (internalBadGateway) ServerError() {
|
|||
func (internalBadGateway) BadGateway() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalBadGateway) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalBadRequest) ClientError() {
|
|||
func (internalBadRequest) BadRequest() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalBadRequest) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalConflict) ClientError() {
|
|||
func (internalConflict) Conflict() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalConflict) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
1
error.go
1
error.go
|
@ -3,4 +3,5 @@ package errhttp
|
|||
type Error interface {
|
||||
error
|
||||
Err() error
|
||||
Unwrap() error
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalExpectationFailed) ClientError() {
|
|||
func (internalExpectationFailed) ExpectationFailed() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalExpectationFailed) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -31,3 +31,6 @@ func (internalFailedDependency) FailedDependency() {
|
|||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalFailedDependency) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -31,3 +31,6 @@ func (internalForbidden) Forbidden() {
|
|||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalForbidden) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ type GatewayTimeout interface {
|
|||
GatewayTimeout()
|
||||
}
|
||||
|
||||
var _ GatewayTimeout = internalGatewayTimeout{}
|
||||
|
||||
type internalGatewayTimeout struct {
|
||||
err error
|
||||
}
|
||||
|
@ -30,3 +32,7 @@ func (internalGatewayTimeout) ServerError() {
|
|||
func (internalGatewayTimeout) GatewayTimeout() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalGatewayTimeout) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
3
gone.go
3
gone.go
|
@ -31,3 +31,6 @@ func (internalGone) Gone() {
|
|||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalGone) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ type HTTPVersionNotSupported interface {
|
|||
HTTPVersionNotSupported()
|
||||
}
|
||||
|
||||
var _ HTTPVersionNotSupported = internalHTTPVersionNotSupported{}
|
||||
|
||||
type internalHTTPVersionNotSupported struct {
|
||||
err error
|
||||
}
|
||||
|
@ -30,3 +32,7 @@ func (internalHTTPVersionNotSupported) ServerError() {
|
|||
func (internalHTTPVersionNotSupported) HTTPVersionNotSupported() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalHTTPVersionNotSupported) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ type InsufficientStorage interface {
|
|||
InsufficientStorage()
|
||||
}
|
||||
|
||||
var _ InsufficientStorage = internalInsufficientStorage{}
|
||||
|
||||
type internalInsufficientStorage struct {
|
||||
err error
|
||||
}
|
||||
|
@ -30,3 +32,7 @@ func (internalInsufficientStorage) ServerError() {
|
|||
func (internalInsufficientStorage) InsufficientStorage() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalInsufficientStorage) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ type InternalServerError interface {
|
|||
InternalServerError()
|
||||
}
|
||||
|
||||
var _ InternalServerError = internalInternalServerError{}
|
||||
|
||||
type internalInternalServerError struct {
|
||||
err error
|
||||
}
|
||||
|
@ -30,3 +32,7 @@ func (internalInternalServerError) ServerError() {
|
|||
func (internalInternalServerError) InternalServerError() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalInternalServerError) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -31,3 +31,6 @@ func (internalLengthRequired) LengthRequired() {
|
|||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalLengthRequired) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalLocked) ClientError() {
|
|||
func (internalLocked) Locked() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalLocked) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ type LoopDetected interface {
|
|||
LoopDetected()
|
||||
}
|
||||
|
||||
var _ LoopDetected = internalLoopDetected{}
|
||||
|
||||
type internalLoopDetected struct {
|
||||
err error
|
||||
}
|
||||
|
@ -30,3 +32,7 @@ func (internalLoopDetected) ServerError() {
|
|||
func (internalLoopDetected) LoopDetected() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalLoopDetected) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -31,3 +31,6 @@ func (internalMethodNotAllowed) MethodNotAllowed() {
|
|||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalMethodNotAllowed) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ type NetworkAuthenticationRequired interface {
|
|||
NetworkAuthenticationRequired()
|
||||
}
|
||||
|
||||
var _ NetworkAuthenticationRequired = internalNetworkAuthenticationRequired{}
|
||||
|
||||
type internalNetworkAuthenticationRequired struct {
|
||||
err error
|
||||
}
|
||||
|
@ -30,3 +32,7 @@ func (internalNetworkAuthenticationRequired) ServerError() {
|
|||
func (internalNetworkAuthenticationRequired) NetworkAuthenticationRequired() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalNetworkAuthenticationRequired) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalNotAcceptable) ClientError() {
|
|||
func (internalNotAcceptable) NotAcceptable() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalNotAcceptable) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ type NotExtended interface {
|
|||
NotExtended()
|
||||
}
|
||||
|
||||
var _ NotExtended = internalNotExtended{}
|
||||
|
||||
type internalNotExtended struct {
|
||||
err error
|
||||
}
|
||||
|
@ -30,3 +32,7 @@ func (internalNotExtended) ServerError() {
|
|||
func (internalNotExtended) NotExtended() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalNotExtended) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalNotFound ) ClientError() {
|
|||
func (internalNotFound ) NotFound() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalNotFound) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ type NotImplemented interface {
|
|||
NotImplemented()
|
||||
}
|
||||
|
||||
var _ NotImplemented = internalNotImplemented{}
|
||||
|
||||
type internalNotImplemented struct {
|
||||
err error
|
||||
}
|
||||
|
@ -30,3 +32,7 @@ func (internalNotImplemented) ServerError() {
|
|||
func (internalNotImplemented) NotImplemented() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalNotImplemented) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalPayloadTooLarge) ClientError() {
|
|||
func (internalPayloadTooLarge) PayloadTooLarge() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalPayloadTooLarge) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalPaymentRequired) ClientError() {
|
|||
func (internalPaymentRequired) PaymentRequired() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalPaymentRequired) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalPreconditionFailed) ClientError() {
|
|||
func (internalPreconditionFailed) PreconditionFailed() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalPreconditionFailed) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -31,3 +31,6 @@ func (internalPreconditionRequired) PreconditionRequired() {
|
|||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalPreconditionRequired) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalProxyAuthRequired) ClientError() {
|
|||
func (internalProxyAuthRequired) ProxyAuthRequired() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalProxyAuthRequired) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalRequestedRangeNotSatisfiable) ClientError() {
|
|||
func (internalRequestedRangeNotSatisfiable) RequestedRangeNotSatisfiable() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalRequestedRangeNotSatisfiable) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalRequestEntityTooLarge) ClientError() {
|
|||
func (internalRequestEntityTooLarge) RequestEntityTooLarge() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalRequestEntityTooLarge) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -31,3 +31,7 @@ func (internalRequestHeaderFieldsTooLarge) ClientError() {
|
|||
func (internalRequestHeaderFieldsTooLarge) RequestHeaderFieldsTooLarge() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalRequestHeaderFieldsTooLarge) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -31,3 +31,7 @@ func (internalRequestTimeout) ClientError() {
|
|||
func (internalRequestTimeout) RequestTimeout() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalRequestTimeout) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -31,3 +31,7 @@ func (internalRequestURITooLong) ClientError() {
|
|||
func (internalRequestURITooLong) RequestURITooLong() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalRequestURITooLong) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalServiceUnavailable) ServerError() {
|
|||
func (internalServiceUnavailable) ServiceUnavailable() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalServiceUnavailable) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalTeapot) ClientError() {
|
|||
func (internalTeapot) Teapot() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalTeapot) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalTooManyRequests) ClientError() {
|
|||
func (internalTooManyRequests) TooManyRequests() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalTooManyRequests) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalUnauthorized) ClientError() {
|
|||
func (internalUnauthorized) Unauthorized() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalUnauthorized) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -31,3 +31,6 @@ func (internalUnavailableForLegalReasons) UnavailableForLegalReasons() {
|
|||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalUnavailableForLegalReasons) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalUnprocessableEntity) ClientError() {
|
|||
func (internalUnprocessableEntity) UnprocessableEntity() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalUnprocessableEntity) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalUnsupportedMediaType) ClientError() {
|
|||
func (internalUnsupportedMediaType) UnsupportedMediaType() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalUnsupportedMediaType) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalUpgradeRequired) ClientError() {
|
|||
func (internalUpgradeRequired) UpgradeRequired() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalUpgradeRequired) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -30,3 +30,7 @@ func (internalURITooLong) ClientError() {
|
|||
func (internalURITooLong) URITooLong() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalURITooLong) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ type VariantAlsoNegotiates interface {
|
|||
VariantAlsoNegotiates()
|
||||
}
|
||||
|
||||
var _ VariantAlsoNegotiates = internalVariantAlsoNegotiates{}
|
||||
|
||||
type internalVariantAlsoNegotiates struct {
|
||||
err error
|
||||
}
|
||||
|
@ -30,3 +32,7 @@ func (internalVariantAlsoNegotiates) ServerError() {
|
|||
func (internalVariantAlsoNegotiates) VariantAlsoNegotiates() {
|
||||
// Nothing here.
|
||||
}
|
||||
|
||||
func (receiver internalVariantAlsoNegotiates) Unwrap() error {
|
||||
return receiver.err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue