From 593a440c118bfe5cca2699a0d8891d2a8f006fbb Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Thu, 16 Feb 2023 12:01:00 -0800 Subject: [PATCH] added .ErrHTTP() method so can detect these are these type of errors --- badgateway.go | 4 ++++ badrequest.go | 4 ++++ conflict.go | 4 ++++ error.go | 1 + expectationfailed.go | 4 ++++ faileddependency.go | 4 ++++ forbidden.go | 4 ++++ gatewaytimeout.go | 4 ++++ gone.go | 4 ++++ httpversionnotsupported.go | 4 ++++ insufficientstorage.go | 4 ++++ internalservererror.go | 4 ++++ lengthrequired.go | 4 ++++ locked.go | 4 ++++ loopdetected.go | 4 ++++ methodnotallowed.go | 4 ++++ networkauthenticationrequired.go | 4 ++++ notacceptable.go | 4 ++++ notextended.go | 4 ++++ notfound.go | 4 ++++ notimplemented.go | 4 ++++ payloadtoolarge.go | 4 ++++ paymentrequired.go | 5 +++++ preconditionfailed.go | 4 ++++ preconditionrequired.go | 4 ++++ proxyauthrequired.go | 4 ++++ requestedrangenotsatisfiable.go | 4 ++++ requestentitytoolarge.go | 4 ++++ requestheaderfieldstoolarge.go | 4 ++++ requesttimeout.go | 4 ++++ requesturitoolong.go | 4 ++++ serviceunavailable.go | 4 ++++ teapot.go | 4 ++++ toomanyrequests.go | 4 ++++ unauthorized.go | 4 ++++ unavailableforlegalreasons.go | 4 ++++ unprocessableentity.go | 4 ++++ unsupportedmediatype.go | 4 ++++ upgraderequired.go | 4 ++++ uritoolong.go | 4 ++++ variantaisonegotiates.go | 4 ++++ 41 files changed, 162 insertions(+) diff --git a/badgateway.go b/badgateway.go index b7b25f1..56574fe 100644 --- a/badgateway.go +++ b/badgateway.go @@ -31,6 +31,10 @@ func (receiver internalBadGateway) Err() error { return receiver.err } +func (internalBadGateway) ErrHTTP() { + // Nothing here. +} + func (internalBadGateway) ServerError() { // Nothing here. } diff --git a/badrequest.go b/badrequest.go index 4b0e64a..af09b8d 100644 --- a/badrequest.go +++ b/badrequest.go @@ -29,6 +29,10 @@ func (receiver internalBadRequest) Err() error { return receiver.err } +func (internalBadRequest) ErrHTTP() { + // Nothing here. +} + func (internalBadRequest) ClientError() { // Nothing here. } diff --git a/conflict.go b/conflict.go index c695502..a0ebe0e 100644 --- a/conflict.go +++ b/conflict.go @@ -29,6 +29,10 @@ func (receiver internalConflict) Err() error { return receiver.err } +func (internalConflict) ErrHTTP() { + // Nothing here. +} + func (internalConflict) ClientError() { // Nothing here. } diff --git a/error.go b/error.go index 17b99a0..387c276 100644 --- a/error.go +++ b/error.go @@ -3,5 +3,6 @@ package errhttp type Error interface { error Err() error + ErrHTTP() Unwrap() error } diff --git a/expectationfailed.go b/expectationfailed.go index 09b2aca..92cce59 100644 --- a/expectationfailed.go +++ b/expectationfailed.go @@ -29,6 +29,10 @@ func (receiver internalExpectationFailed) Err() error { return receiver.err } +func (internalExpectationFailed) ErrHTTP() { + // Nothing here. +} + func (internalExpectationFailed) ClientError() { // Nothing here. } diff --git a/faileddependency.go b/faileddependency.go index d832082..df6f180 100644 --- a/faileddependency.go +++ b/faileddependency.go @@ -29,6 +29,10 @@ func (receiver internalFailedDependency) Err() error { return receiver.err } +func (internalFailedDependency) ErrHTTP() { + // Nothing here. +} + func (internalFailedDependency) ClientError() { // Nothing here. } diff --git a/forbidden.go b/forbidden.go index 7b61d8b..5a4d890 100644 --- a/forbidden.go +++ b/forbidden.go @@ -29,6 +29,10 @@ func (receiver internalForbidden) Err() error { return receiver.err } +func (internalForbidden) ErrHTTP() { + // Nothing here. +} + func (internalForbidden) ClientError() { // Nothing here. } diff --git a/gatewaytimeout.go b/gatewaytimeout.go index e12d1a9..c33e0b5 100644 --- a/gatewaytimeout.go +++ b/gatewaytimeout.go @@ -31,6 +31,10 @@ func (receiver internalGatewayTimeout) Err() error { return receiver.err } +func (internalGatewayTimeout) ErrHTTP() { + // Nothing here. +} + func (internalGatewayTimeout) ServerError() { // Nothing here. } diff --git a/gone.go b/gone.go index 3514b32..cb8a2da 100644 --- a/gone.go +++ b/gone.go @@ -29,6 +29,10 @@ func (receiver internalGone) Err() error { return receiver.err } +func (internalGone) ErrHTTP() { + // Nothing here. +} + func (internalGone) ClientError() { // Nothing here. } diff --git a/httpversionnotsupported.go b/httpversionnotsupported.go index 2092691..97095a0 100644 --- a/httpversionnotsupported.go +++ b/httpversionnotsupported.go @@ -31,6 +31,10 @@ func (receiver internalHTTPVersionNotSupported) Err() error { return receiver.err } +func (internalHTTPVersionNotSupported) ErrHTTP() { + // Nothing here. +} + func (internalHTTPVersionNotSupported) ServerError() { // Nothing here. } diff --git a/insufficientstorage.go b/insufficientstorage.go index b19d35b..1eb924b 100644 --- a/insufficientstorage.go +++ b/insufficientstorage.go @@ -31,6 +31,10 @@ func (receiver internalInsufficientStorage) Err() error { return receiver.err } +func (internalInsufficientStorage) ErrHTTP() { + // Nothing here. +} + func (internalInsufficientStorage) ServerError() { // Nothing here. } diff --git a/internalservererror.go b/internalservererror.go index 6ce58d5..092396f 100644 --- a/internalservererror.go +++ b/internalservererror.go @@ -31,6 +31,10 @@ func (receiver internalInternalServerError) Err() error { return receiver.err } +func (internalInternalServerError) ErrHTTP() { + // Nothing here. +} + func (internalInternalServerError) ServerError() { // Nothing here. } diff --git a/lengthrequired.go b/lengthrequired.go index 6abf2e3..42fb0db 100644 --- a/lengthrequired.go +++ b/lengthrequired.go @@ -29,6 +29,10 @@ func (receiver internalLengthRequired) Err() error { return receiver.err } +func (internalLengthRequired) ErrHTTP() { + // Nothing here. +} + func (internalLengthRequired) ClientError() { // Nothing here. } diff --git a/locked.go b/locked.go index 1ebcf4d..0644b01 100644 --- a/locked.go +++ b/locked.go @@ -29,6 +29,10 @@ func (receiver internalLocked) Err() error { return receiver.err } +func (internalLocked) ErrHTTP() { + // Nothing here. +} + func (internalLocked) ClientError() { // Nothing here. } diff --git a/loopdetected.go b/loopdetected.go index ec7bed5..9f2992e 100644 --- a/loopdetected.go +++ b/loopdetected.go @@ -31,6 +31,10 @@ func (receiver internalLoopDetected) Err() error { return receiver.err } +func (internalLoopDetected) ErrHTTP() { + // Nothing here. +} + func (internalLoopDetected) ServerError() { // Nothing here. } diff --git a/methodnotallowed.go b/methodnotallowed.go index 2e418f7..6d5a7cc 100644 --- a/methodnotallowed.go +++ b/methodnotallowed.go @@ -29,6 +29,10 @@ func (receiver internalMethodNotAllowed) Err() error { return receiver.err } +func (internalMethodNotAllowed) ErrHTTP() { + // Nothing here. +} + func (internalMethodNotAllowed) ClientError() { // Nothing here. } diff --git a/networkauthenticationrequired.go b/networkauthenticationrequired.go index a56ba3e..468313b 100644 --- a/networkauthenticationrequired.go +++ b/networkauthenticationrequired.go @@ -31,6 +31,10 @@ func (receiver internalNetworkAuthenticationRequired) Err() error { return receiver.err } +func (internalNetworkAuthenticationRequired) ErrHTTP() { + // Nothing here. +} + func (internalNetworkAuthenticationRequired) ServerError() { // Nothing here. } diff --git a/notacceptable.go b/notacceptable.go index 527fe32..ac4da30 100644 --- a/notacceptable.go +++ b/notacceptable.go @@ -29,6 +29,10 @@ func (receiver internalNotAcceptable) Err() error { return receiver.err } +func (internalNotAcceptable) ErrHTTP() { + // Nothing here. +} + func (internalNotAcceptable) ClientError() { // Nothing here. } diff --git a/notextended.go b/notextended.go index 47b229d..f997fd0 100644 --- a/notextended.go +++ b/notextended.go @@ -31,6 +31,10 @@ func (receiver internalNotExtended) Err() error { return receiver.err } +func (internalNotExtended) ErrHTTP() { + // Nothing here. +} + func (internalNotExtended) ServerError() { // Nothing here. } diff --git a/notfound.go b/notfound.go index 9dc8349..50cfa96 100644 --- a/notfound.go +++ b/notfound.go @@ -29,6 +29,10 @@ func (receiver internalNotFound ) Err() error { return receiver.err } +func (internalNotFound ) ErrHTTP() { + // Nothing here. +} + func (internalNotFound ) ClientError() { // Nothing here. } diff --git a/notimplemented.go b/notimplemented.go index de7d2cb..33780cf 100644 --- a/notimplemented.go +++ b/notimplemented.go @@ -31,6 +31,10 @@ func (receiver internalNotImplemented) Err() error { return receiver.err } +func (internalNotImplemented) ErrHTTP() { + // Nothing here. +} + func (internalNotImplemented) ServerError() { // Nothing here. } diff --git a/payloadtoolarge.go b/payloadtoolarge.go index bd56f6f..208409b 100644 --- a/payloadtoolarge.go +++ b/payloadtoolarge.go @@ -29,6 +29,10 @@ func (receiver internalPayloadTooLarge) Err() error { return receiver.err } +func (internalPayloadTooLarge) ErrHTTP() { + // Nothing here. +} + func (internalPayloadTooLarge) ClientError() { // Nothing here. } diff --git a/paymentrequired.go b/paymentrequired.go index db74e93..56651fd 100644 --- a/paymentrequired.go +++ b/paymentrequired.go @@ -29,6 +29,11 @@ func (receiver internalPaymentRequired) Err() error { return receiver.err } +func (internalPaymentRequired) ErrHTTP() { + // Nothing here. +} + + func (internalPaymentRequired) ClientError() { // Nothing here. } diff --git a/preconditionfailed.go b/preconditionfailed.go index 0ab7c7b..1f0a892 100644 --- a/preconditionfailed.go +++ b/preconditionfailed.go @@ -29,6 +29,10 @@ func (receiver internalPreconditionFailed) Err() error { return receiver.err } +func (internalPreconditionFailed) ErrHTTP() { + // Nothing here. +} + func (internalPreconditionFailed) ClientError() { // Nothing here. } diff --git a/preconditionrequired.go b/preconditionrequired.go index 776359a..03b8e0d 100644 --- a/preconditionrequired.go +++ b/preconditionrequired.go @@ -29,6 +29,10 @@ func (receiver internalPreconditionRequired) Err() error { return receiver.err } +func (internalPreconditionRequired) ErrHTTP() { + // Nothing here. +} + func (internalPreconditionRequired) ClientError() { // Nothing here. } diff --git a/proxyauthrequired.go b/proxyauthrequired.go index 19baf39..a90137f 100644 --- a/proxyauthrequired.go +++ b/proxyauthrequired.go @@ -29,6 +29,10 @@ func (receiver internalProxyAuthRequired) Err() error { return receiver.err } +func (internalProxyAuthRequired) ErrHTTP() { + // Nothing here. +} + func (internalProxyAuthRequired) ClientError() { // Nothing here. } diff --git a/requestedrangenotsatisfiable.go b/requestedrangenotsatisfiable.go index ce46f6f..799b779 100644 --- a/requestedrangenotsatisfiable.go +++ b/requestedrangenotsatisfiable.go @@ -29,6 +29,10 @@ func (receiver internalRequestedRangeNotSatisfiable) Err() error { return receiver.err } +func (internalRequestedRangeNotSatisfiable) ErrHTTP() { + // Nothing here. +} + func (internalRequestedRangeNotSatisfiable) ClientError() { // Nothing here. } diff --git a/requestentitytoolarge.go b/requestentitytoolarge.go index 5595877..735330e 100644 --- a/requestentitytoolarge.go +++ b/requestentitytoolarge.go @@ -29,6 +29,10 @@ func (receiver internalRequestEntityTooLarge) Err() error { return receiver.err } +func (internalRequestEntityTooLarge) ErrHTTP() { + // Nothing here. +} + func (internalRequestEntityTooLarge) ClientError() { // Nothing here. } diff --git a/requestheaderfieldstoolarge.go b/requestheaderfieldstoolarge.go index a0aa81b..9dd6d80 100644 --- a/requestheaderfieldstoolarge.go +++ b/requestheaderfieldstoolarge.go @@ -30,6 +30,10 @@ func (receiver internalRequestHeaderFieldsTooLarge) Err() error { return receiver.err } +func (internalRequestHeaderFieldsTooLarge) ErrHTTP() { + // Nothing here. +} + func (internalRequestHeaderFieldsTooLarge) ClientError() { // Nothing here. } diff --git a/requesttimeout.go b/requesttimeout.go index ce96d12..49912a2 100644 --- a/requesttimeout.go +++ b/requesttimeout.go @@ -30,6 +30,10 @@ func (receiver internalRequestTimeout) Err() error { return receiver.err } +func (internalRequestTimeout) ErrHTTP() { + // Nothing here. +} + func (internalRequestTimeout) ClientError() { // Nothing here. } diff --git a/requesturitoolong.go b/requesturitoolong.go index da015a6..a6ef238 100644 --- a/requesturitoolong.go +++ b/requesturitoolong.go @@ -30,6 +30,10 @@ func (receiver internalRequestURITooLong) Err() error { return receiver.err } +func (internalRequestURITooLong) ErrHTTP() { + // Nothing here. +} + func (internalRequestURITooLong) ClientError() { // Nothing here. } diff --git a/serviceunavailable.go b/serviceunavailable.go index 59e2390..4645900 100644 --- a/serviceunavailable.go +++ b/serviceunavailable.go @@ -29,6 +29,10 @@ func (receiver internalServiceUnavailable) Err() error { return receiver.err } +func (internalServiceUnavailable) ErrHTTP() { + // Nothing here. +} + func (internalServiceUnavailable) ServerError() { // Nothing here. } diff --git a/teapot.go b/teapot.go index 09679a0..1ddcd19 100644 --- a/teapot.go +++ b/teapot.go @@ -29,6 +29,10 @@ func (receiver internalTeapot) Err() error { return receiver.err } +func (internalTeapot) ErrHTTP() { + // Nothing here. +} + func (internalTeapot) ClientError() { // Nothing here. } diff --git a/toomanyrequests.go b/toomanyrequests.go index 6181e76..6d23323 100644 --- a/toomanyrequests.go +++ b/toomanyrequests.go @@ -29,6 +29,10 @@ func (receiver internalTooManyRequests) Err() error { return receiver.err } +func (internalTooManyRequests) ErrHTTP() { + // Nothing here. +} + func (internalTooManyRequests) ClientError() { // Nothing here. } diff --git a/unauthorized.go b/unauthorized.go index 7cd6b18..77bc93c 100644 --- a/unauthorized.go +++ b/unauthorized.go @@ -29,6 +29,10 @@ func (receiver internalUnauthorized) Err() error { return receiver.err } +func (internalUnauthorized) ErrHTTP() { + // Nothing here. +} + func (internalUnauthorized) ClientError() { // Nothing here. } diff --git a/unavailableforlegalreasons.go b/unavailableforlegalreasons.go index 6ad7990..172f209 100644 --- a/unavailableforlegalreasons.go +++ b/unavailableforlegalreasons.go @@ -29,6 +29,10 @@ func (receiver internalUnavailableForLegalReasons) Err() error { return receiver.err } +func (internalUnavailableForLegalReasons) ErrHTTP() { + // Nothing here. +} + func (internalUnavailableForLegalReasons) ClientError() { // Nothing here. } diff --git a/unprocessableentity.go b/unprocessableentity.go index 06c8088..4e1e02b 100644 --- a/unprocessableentity.go +++ b/unprocessableentity.go @@ -29,6 +29,10 @@ func (receiver internalUnprocessableEntity) Err() error { return receiver.err } +func (internalUnprocessableEntity) ErrHTTP() { + // Nothing here. +} + func (internalUnprocessableEntity) ClientError() { // Nothing here. } diff --git a/unsupportedmediatype.go b/unsupportedmediatype.go index f1fbc11..528d058 100644 --- a/unsupportedmediatype.go +++ b/unsupportedmediatype.go @@ -29,6 +29,10 @@ func (receiver internalUnsupportedMediaType) Err() error { return receiver.err } +func (internalUnsupportedMediaType) ErrHTTP() { + // Nothing here. +} + func (internalUnsupportedMediaType) ClientError() { // Nothing here. } diff --git a/upgraderequired.go b/upgraderequired.go index 75658fd..d4b9f7e 100644 --- a/upgraderequired.go +++ b/upgraderequired.go @@ -29,6 +29,10 @@ func (receiver internalUpgradeRequired) Err() error { return receiver.err } +func (internalUpgradeRequired) ErrHTTP() { + // Nothing here. +} + func (internalUpgradeRequired) ClientError() { // Nothing here. } diff --git a/uritoolong.go b/uritoolong.go index f3c446b..6590b68 100644 --- a/uritoolong.go +++ b/uritoolong.go @@ -29,6 +29,10 @@ func (receiver internalURITooLong) Err() error { return receiver.err } +func (internalURITooLong) ErrHTTP() { + // Nothing here. +} + func (internalURITooLong) ClientError() { // Nothing here. } diff --git a/variantaisonegotiates.go b/variantaisonegotiates.go index e023b1f..6863cbc 100644 --- a/variantaisonegotiates.go +++ b/variantaisonegotiates.go @@ -31,6 +31,10 @@ func (receiver internalVariantAlsoNegotiates) Err() error { return receiver.err } +func (internalVariantAlsoNegotiates) ErrHTTP() { + // Nothing here. +} + func (internalVariantAlsoNegotiates) ServerError() { // Nothing here. }