made .ErrHTTP() method return the HTTP status code (as an int). added some missing error. removed some errors that should not have been there.

master
Charles Iliya Krempeaux 2023-08-14 06:56:09 -07:00
parent 2f430f79b6
commit ab4070bfdf
44 changed files with 352 additions and 165 deletions

View File

@ -30,12 +30,12 @@ Here is an example of wrapping an error:
//@TODO
case errhttp.InternalServerError:
//@TODO
case errhttp.ClientError:
//@TODO
case errhttp.ServerError:
//@TODO
default:
//@TODO
}
@ -59,12 +59,39 @@ Here is an example of using one of the package global variable errors:
//@TODO
case errhttp.InternalServerError:
//@TODO
case errhttp.ClientError:
//@TODO
case errhttp.ServerError:
//@TODO
default:
//@TODO
}
```
Here is another example, where it used the `.ErrHTTP()` method to get the HTTP response status code:
```go
import "sourcecode.social/reiver/go-errhttp"
// ...
return errhttp.ErrBadRequest
// ...
switch casted := err.(type) {
case errhttp.ClientError:
statuscode := casted.ErrHTTP()
http.Error(responsewriter, http.StatusText(statuscode), statuscode)
return
case errhttp.ServerError:
statuscode := casted.ErrHTTP()
http.Error(responsewriter, http.StatusText(statuscode), statuscode)
return
default:
//@TODO
}

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalBadGateway{}
var _ ServerError = internalBadGateway{}
var _ BadGateway = internalBadGateway{}
@ -27,8 +31,8 @@ func (receiver internalBadGateway) Error() string {
return receiver.err.Error()
}
func (internalBadGateway) ErrHTTP() {
// Nothing here.
func (internalBadGateway) ErrHTTP() int {
return http.StatusBadGateway
}
func (internalBadGateway) ServerError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalBadRequest{}
var _ ClientError = internalBadRequest{}
var _ BadRequest = internalBadRequest{}
@ -25,8 +29,8 @@ func (receiver internalBadRequest) Error() string {
return receiver.err.Error()
}
func (internalBadRequest) ErrHTTP() {
// Nothing here.
func (internalBadRequest) ErrHTTP() int {
return http.StatusBadRequest
}
func (internalBadRequest) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalConflict{}
var _ ClientError = internalConflict{}
var _ Conflict = internalConflict{}
@ -25,8 +29,8 @@ func (receiver internalConflict) Error() string {
return receiver.err.Error()
}
func (internalConflict) ErrHTTP() {
// Nothing here.
func (internalConflict) ErrHTTP() int {
return http.StatusConflict
}
func (internalConflict) ClientError() {

View File

@ -2,6 +2,6 @@ package errhttp
type Error interface {
error
ErrHTTP()
ErrHTTP() int
Unwrap() error
}

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalExpectationFailed{}
var _ ClientError = internalExpectationFailed{}
var _ ExpectationFailed = internalExpectationFailed{}
@ -25,8 +29,8 @@ func (receiver internalExpectationFailed) Error() string {
return receiver.err.Error()
}
func (internalExpectationFailed) ErrHTTP() {
// Nothing here.
func (internalExpectationFailed) ErrHTTP() int {
return http.StatusExpectationFailed
}
func (internalExpectationFailed) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalFailedDependency{}
var _ ClientError = internalFailedDependency{}
var _ FailedDependency = internalFailedDependency{}
@ -25,8 +29,8 @@ func (receiver internalFailedDependency) Error() string {
return receiver.err.Error()
}
func (internalFailedDependency) ErrHTTP() {
// Nothing here.
func (internalFailedDependency) ErrHTTP() int {
return http.StatusFailedDependency
}
func (internalFailedDependency) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalForbidden{}
var _ ClientError = internalForbidden{}
var _ Forbidden = internalForbidden{}
@ -25,8 +29,8 @@ func (receiver internalForbidden) Error() string {
return receiver.err.Error()
}
func (internalForbidden) ErrHTTP() {
// Nothing here.
func (internalForbidden) ErrHTTP() int {
return http.StatusForbidden
}
func (internalForbidden) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalGatewayTimeout{}
var _ ServerError = internalGatewayTimeout{}
var _ GatewayTimeout = internalGatewayTimeout{}
@ -27,8 +31,8 @@ func (receiver internalGatewayTimeout) Error() string {
return receiver.err.Error()
}
func (internalGatewayTimeout) ErrHTTP() {
// Nothing here.
func (internalGatewayTimeout) ErrHTTP() int {
return http.StatusGatewayTimeout
}
func (internalGatewayTimeout) ServerError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalGone{}
var _ ClientError = internalGone{}
var _ Gone = internalGone{}
@ -25,8 +29,8 @@ func (receiver internalGone) Error() string {
return receiver.err.Error()
}
func (internalGone) ErrHTTP() {
// Nothing here.
func (internalGone) ErrHTTP() int {
return http.StatusGone
}
func (internalGone) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalHTTPVersionNotSupported{}
var _ ServerError = internalHTTPVersionNotSupported{}
var _ HTTPVersionNotSupported = internalHTTPVersionNotSupported{}
@ -27,8 +31,8 @@ func (receiver internalHTTPVersionNotSupported) Error() string {
return receiver.err.Error()
}
func (internalHTTPVersionNotSupported) ErrHTTP() {
// Nothing here.
func (internalHTTPVersionNotSupported) ErrHTTP() int {
return http.StatusHTTPVersionNotSupported
}
func (internalHTTPVersionNotSupported) ServerError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalInsufficientStorage{}
var _ ServerError = internalInsufficientStorage{}
var _ InsufficientStorage = internalInsufficientStorage{}
@ -27,8 +31,8 @@ func (receiver internalInsufficientStorage) Error() string {
return receiver.err.Error()
}
func (internalInsufficientStorage) ErrHTTP() {
// Nothing here.
func (internalInsufficientStorage) ErrHTTP() int {
return http.StatusInsufficientStorage
}
func (internalInsufficientStorage) ServerError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalInternalServerError{}
var _ ServerError = internalInternalServerError{}
var _ InternalServerError = internalInternalServerError{}
@ -27,8 +31,8 @@ func (receiver internalInternalServerError) Error() string {
return receiver.err.Error()
}
func (internalInternalServerError) ErrHTTP() {
// Nothing here.
func (internalInternalServerError) ErrHTTP() int {
return http.StatusInternalServerError
}
func (internalInternalServerError) ServerError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalLengthRequired{}
var _ ClientError = internalLengthRequired{}
var _ LengthRequired = internalLengthRequired{}
@ -25,8 +29,8 @@ func (receiver internalLengthRequired) Error() string {
return receiver.err.Error()
}
func (internalLengthRequired) ErrHTTP() {
// Nothing here.
func (internalLengthRequired) ErrHTTP() int {
return http.StatusLengthRequired
}
func (internalLengthRequired) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalLocked{}
var _ ClientError = internalLocked{}
var _ Locked = internalLocked{}
@ -25,8 +29,8 @@ func (receiver internalLocked) Error() string {
return receiver.err.Error()
}
func (internalLocked) ErrHTTP() {
// Nothing here.
func (internalLocked) ErrHTTP() int {
return http.StatusLocked
}
func (internalLocked) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalLoopDetected{}
var _ ServerError = internalLoopDetected{}
var _ LoopDetected = internalLoopDetected{}
@ -27,8 +31,8 @@ func (receiver internalLoopDetected) Error() string {
return receiver.err.Error()
}
func (internalLoopDetected) ErrHTTP() {
// Nothing here.
func (internalLoopDetected) ErrHTTP() int {
return http.StatusLoopDetected
}
func (internalLoopDetected) ServerError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalMethodNotAllowed{}
var _ ClientError = internalMethodNotAllowed{}
var _ MethodNotAllowed = internalMethodNotAllowed{}
@ -25,8 +29,8 @@ func (receiver internalMethodNotAllowed) Error() string {
return receiver.err.Error()
}
func (internalMethodNotAllowed) ErrHTTP() {
// Nothing here.
func (internalMethodNotAllowed) ErrHTTP() int {
return http.StatusMethodNotAllowed
}
func (internalMethodNotAllowed) ClientError() {

View File

@ -0,0 +1,46 @@
package errhttp
import (
"net/http"
)
var _ Error = internalMisdirectedRequest{}
var _ ClientError = internalMisdirectedRequest{}
var _ MisdirectedRequest = internalMisdirectedRequest{}
var ErrMisdirectedRequest = MisdirectedRequestWrap(nil)
type MisdirectedRequest interface {
ClientError
MisdirectedRequest()
}
type internalMisdirectedRequest struct {
err error
}
func MisdirectedRequestWrap(err error) error {
return internalMisdirectedRequest{
err:err,
}
}
func (receiver internalMisdirectedRequest) Error() string {
return receiver.err.Error()
}
func (internalMisdirectedRequest) ErrHTTP() int {
return http.StatusMisdirectedRequest
}
func (internalMisdirectedRequest) ClientError() {
// Nothing here.
}
func (internalMisdirectedRequest) MisdirectedRequest() {
// Nothing here.
}
func (receiver internalMisdirectedRequest) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalNetworkAuthenticationRequired{}
var _ ServerError = internalNetworkAuthenticationRequired{}
var _ NetworkAuthenticationRequired = internalNetworkAuthenticationRequired{}
@ -27,8 +31,8 @@ func (receiver internalNetworkAuthenticationRequired) Error() string {
return receiver.err.Error()
}
func (internalNetworkAuthenticationRequired) ErrHTTP() {
// Nothing here.
func (internalNetworkAuthenticationRequired) ErrHTTP() int {
return http.StatusNetworkAuthenticationRequired
}
func (internalNetworkAuthenticationRequired) ServerError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalNotAcceptable{}
var _ ClientError = internalNotAcceptable{}
var _ NotAcceptable = internalNotAcceptable{}
@ -25,8 +29,8 @@ func (receiver internalNotAcceptable) Error() string {
return receiver.err.Error()
}
func (internalNotAcceptable) ErrHTTP() {
// Nothing here.
func (internalNotAcceptable) ErrHTTP() int {
return http.StatusNotAcceptable
}
func (internalNotAcceptable) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalNotExtended{}
var _ ServerError = internalNotExtended{}
var _ NotExtended = internalNotExtended{}
@ -27,8 +31,8 @@ func (receiver internalNotExtended) Error() string {
return receiver.err.Error()
}
func (internalNotExtended) ErrHTTP() {
// Nothing here.
func (internalNotExtended) ErrHTTP() int {
return http.StatusNotExtended
}
func (internalNotExtended) ServerError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalNotFound{}
var _ ClientError = internalNotFound{}
var _ NotFound = internalNotFound{}
@ -25,8 +29,8 @@ func (receiver internalNotFound ) Error() string {
return receiver.err.Error()
}
func (internalNotFound ) ErrHTTP() {
// Nothing here.
func (internalNotFound ) ErrHTTP() int {
return http.StatusNotFound
}
func (internalNotFound ) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalNotImplemented{}
var _ ServerError = internalNotImplemented{}
var _ NotImplemented = internalNotImplemented{}
@ -27,8 +31,8 @@ func (receiver internalNotImplemented) Error() string {
return receiver.err.Error()
}
func (internalNotImplemented) ErrHTTP() {
// Nothing here.
func (internalNotImplemented) ErrHTTP() int {
return http.StatusNotImplemented
}
func (internalNotImplemented) ServerError() {

View File

@ -1,42 +0,0 @@
package errhttp
var _ Error = internalPayloadTooLarge{}
var _ ClientError = internalPayloadTooLarge{}
var _ PayloadTooLarge = internalPayloadTooLarge{}
var ErrPayloadTooLarge error = PayloadTooLargeWrap(nil)
type PayloadTooLarge interface {
ClientError
PayloadTooLarge()
}
type internalPayloadTooLarge struct {
err error
}
func PayloadTooLargeWrap(err error) error {
return internalPayloadTooLarge{
err:err,
}
}
func (receiver internalPayloadTooLarge) Error() string {
return receiver.err.Error()
}
func (internalPayloadTooLarge) ErrHTTP() {
// Nothing here.
}
func (internalPayloadTooLarge) ClientError() {
// Nothing here.
}
func (internalPayloadTooLarge) PayloadTooLarge() {
// Nothing here.
}
func (receiver internalPayloadTooLarge) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalPaymentRequired{}
var _ ClientError = internalPaymentRequired{}
var _ PaymentRequired = internalPaymentRequired{}
@ -25,8 +29,8 @@ func (receiver internalPaymentRequired) Error() string {
return receiver.err.Error()
}
func (internalPaymentRequired) ErrHTTP() {
// Nothing here.
func (internalPaymentRequired) ErrHTTP() int {
return http.StatusPaymentRequired
}

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalPreconditionFailed{}
var _ ClientError = internalPreconditionFailed{}
var _ PreconditionFailed = internalPreconditionFailed{}
@ -25,8 +29,8 @@ func (receiver internalPreconditionFailed) Error() string {
return receiver.err.Error()
}
func (internalPreconditionFailed) ErrHTTP() {
// Nothing here.
func (internalPreconditionFailed) ErrHTTP() int {
return http.StatusPreconditionFailed
}
func (internalPreconditionFailed) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalPreconditionRequired{}
var _ ClientError = internalPreconditionRequired{}
var _ PreconditionRequired = internalPreconditionRequired{}
@ -25,8 +29,8 @@ func (receiver internalPreconditionRequired) Error() string {
return receiver.err.Error()
}
func (internalPreconditionRequired) ErrHTTP() {
// Nothing here.
func (internalPreconditionRequired) ErrHTTP() int {
return http.StatusPreconditionRequired
}
func (internalPreconditionRequired) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalProxyAuthRequired{}
var _ ClientError = internalProxyAuthRequired{}
var _ ProxyAuthRequired = internalProxyAuthRequired{}
@ -25,8 +29,8 @@ func (receiver internalProxyAuthRequired) Error() string {
return receiver.err.Error()
}
func (internalProxyAuthRequired) ErrHTTP() {
// Nothing here.
func (internalProxyAuthRequired) ErrHTTP() int {
return http.StatusProxyAuthRequired
}
func (internalProxyAuthRequired) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalRequestedRangeNotSatisfiable{}
var _ ClientError = internalRequestedRangeNotSatisfiable{}
var _ RequestedRangeNotSatisfiable = internalRequestedRangeNotSatisfiable{}
@ -25,8 +29,8 @@ func (receiver internalRequestedRangeNotSatisfiable) Error() string {
return receiver.err.Error()
}
func (internalRequestedRangeNotSatisfiable) ErrHTTP() {
// Nothing here.
func (internalRequestedRangeNotSatisfiable) ErrHTTP() int {
return http.StatusRequestedRangeNotSatisfiable
}
func (internalRequestedRangeNotSatisfiable) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalRequestEntityTooLarge{}
var _ ClientError = internalRequestEntityTooLarge{}
var _ RequestEntityTooLarge = internalRequestEntityTooLarge{}
@ -25,8 +29,8 @@ func (receiver internalRequestEntityTooLarge) Error() string {
return receiver.err.Error()
}
func (internalRequestEntityTooLarge) ErrHTTP() {
// Nothing here.
func (internalRequestEntityTooLarge) ErrHTTP() int {
return http.StatusRequestEntityTooLarge
}
func (internalRequestEntityTooLarge) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalRequestHeaderFieldsTooLarge{}
var _ ClientError = internalRequestHeaderFieldsTooLarge{}
var _ RequestHeaderFieldsTooLarge = internalRequestHeaderFieldsTooLarge{}
@ -25,8 +29,8 @@ func (receiver internalRequestHeaderFieldsTooLarge) Error() string {
return receiver.err.Error()
}
func (internalRequestHeaderFieldsTooLarge) ErrHTTP() {
// Nothing here.
func (internalRequestHeaderFieldsTooLarge) ErrHTTP() int {
return http.StatusRequestHeaderFieldsTooLarge
}
func (internalRequestHeaderFieldsTooLarge) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalRequestTimeout{}
var _ ClientError = internalRequestTimeout{}
var _ RequestTimeout = internalRequestTimeout{}
@ -25,8 +29,8 @@ func (receiver internalRequestTimeout) Error() string {
return receiver.err.Error()
}
func (internalRequestTimeout) ErrHTTP() {
// Nothing here.
func (internalRequestTimeout) ErrHTTP() int {
return http.StatusRequestTimeout
}
func (internalRequestTimeout) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalRequestURITooLong{}
var _ ClientError = internalRequestURITooLong{}
var _ RequestURITooLong = internalRequestURITooLong{}
@ -25,8 +29,8 @@ func (receiver internalRequestURITooLong) Error() string {
return receiver.err.Error()
}
func (internalRequestURITooLong) ErrHTTP() {
// Nothing here.
func (internalRequestURITooLong) ErrHTTP() int {
return http.StatusRequestURITooLong
}
func (internalRequestURITooLong) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalServiceUnavailable{}
var _ ServerError = internalServiceUnavailable{}
var _ ServiceUnavailable = internalServiceUnavailable{}
@ -25,8 +29,8 @@ func (receiver internalServiceUnavailable) Error() string {
return receiver.err.Error()
}
func (internalServiceUnavailable) ErrHTTP() {
// Nothing here.
func (internalServiceUnavailable) ErrHTTP() int {
return http.StatusServiceUnavailable
}
func (internalServiceUnavailable) ServerError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalTeapot{}
var _ ClientError = internalTeapot{}
var _ Teapot = internalTeapot{}
@ -25,8 +29,8 @@ func (receiver internalTeapot) Error() string {
return receiver.err.Error()
}
func (internalTeapot) ErrHTTP() {
// Nothing here.
func (internalTeapot) ErrHTTP() int {
return http.StatusTeapot
}
func (internalTeapot) ClientError() {

46
tooearly.go 100644
View File

@ -0,0 +1,46 @@
package errhttp
import (
"net/http"
)
var _ Error = internalTooEarly{}
var _ ClientError = internalTooEarly{}
var _ TooEarly = internalTooEarly{}
var ErrTooEarly = TooEarlyWrap(nil)
type TooEarly interface {
ClientError
TooEarly()
}
type internalTooEarly struct {
err error
}
func TooEarlyWrap(err error) error {
return internalTooEarly{
err:err,
}
}
func (receiver internalTooEarly) Error() string {
return receiver.err.Error()
}
func (internalTooEarly) ErrHTTP() int {
return http.StatusTooEarly
}
func (internalTooEarly) ClientError() {
// Nothing here.
}
func (internalTooEarly) TooEarly() {
// Nothing here.
}
func (receiver internalTooEarly) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalTooManyRequests{}
var _ ClientError = internalTooManyRequests{}
var _ TooManyRequests = internalTooManyRequests{}
@ -25,8 +29,8 @@ func (receiver internalTooManyRequests) Error() string {
return receiver.err.Error()
}
func (internalTooManyRequests) ErrHTTP() {
// Nothing here.
func (internalTooManyRequests) ErrHTTP() int {
return http.StatusTooManyRequests
}
func (internalTooManyRequests) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalUnauthorized{}
var _ ClientError = internalUnauthorized{}
var _ Unauthorized = internalUnauthorized{}
@ -25,8 +29,8 @@ func (receiver internalUnauthorized) Error() string {
return receiver.err.Error()
}
func (internalUnauthorized) ErrHTTP() {
// Nothing here.
func (internalUnauthorized) ErrHTTP() int {
return http.StatusUnauthorized
}
func (internalUnauthorized) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalUnavailableForLegalReasons{}
var _ ClientError = internalUnavailableForLegalReasons{}
var _ UnavailableForLegalReasons = internalUnavailableForLegalReasons{}
@ -25,8 +29,8 @@ func (receiver internalUnavailableForLegalReasons) Error() string {
return receiver.err.Error()
}
func (internalUnavailableForLegalReasons) ErrHTTP() {
// Nothing here.
func (internalUnavailableForLegalReasons) ErrHTTP() int {
return http.StatusUnavailableForLegalReasons
}
func (internalUnavailableForLegalReasons) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalUnprocessableEntity{}
var _ ClientError = internalUnprocessableEntity{}
var _ UnprocessableEntity = internalUnprocessableEntity{}
@ -25,8 +29,8 @@ func (receiver internalUnprocessableEntity) Error() string {
return receiver.err.Error()
}
func (internalUnprocessableEntity) ErrHTTP() {
// Nothing here.
func (internalUnprocessableEntity) ErrHTTP() int {
return http.StatusUnprocessableEntity
}
func (internalUnprocessableEntity) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalUnsupportedMediaType{}
var _ ClientError = internalUnsupportedMediaType{}
var _ UnsupportedMediaType = internalUnsupportedMediaType{}
@ -25,8 +29,8 @@ func (receiver internalUnsupportedMediaType) Error() string {
return receiver.err.Error()
}
func (internalUnsupportedMediaType) ErrHTTP() {
// Nothing here.
func (internalUnsupportedMediaType) ErrHTTP() int {
return http.StatusUnsupportedMediaType
}
func (internalUnsupportedMediaType) ClientError() {

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalUpgradeRequired{}
var _ ClientError = internalUpgradeRequired{}
var _ UpgradeRequired = internalUpgradeRequired{}
@ -25,8 +29,8 @@ func (receiver internalUpgradeRequired) Error() string {
return receiver.err.Error()
}
func (internalUpgradeRequired) ErrHTTP() {
// Nothing here.
func (internalUpgradeRequired) ErrHTTP() int {
return http.StatusUpgradeRequired
}
func (internalUpgradeRequired) ClientError() {

View File

@ -1,42 +0,0 @@
package errhttp
var _ Error = internalURITooLong{}
var _ ClientError = internalURITooLong{}
var _ URITooLong = internalURITooLong{}
var ErrURITooLong error = URITooLongWrap(nil)
type URITooLong interface {
ClientError
URITooLong()
}
type internalURITooLong struct {
err error
}
func URITooLongWrap(err error) error {
return internalURITooLong{
err:err,
}
}
func (receiver internalURITooLong) Error() string {
return receiver.err.Error()
}
func (internalURITooLong) ErrHTTP() {
// Nothing here.
}
func (internalURITooLong) ClientError() {
// Nothing here.
}
func (internalURITooLong) URITooLong() {
// Nothing here.
}
func (receiver internalURITooLong) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,9 @@
package errhttp
import (
"net/http"
)
var _ Error = internalVariantAlsoNegotiates{}
var _ ServerError = internalVariantAlsoNegotiates{}
var _ VariantAlsoNegotiates = internalVariantAlsoNegotiates{}
@ -27,8 +31,8 @@ func (receiver internalVariantAlsoNegotiates) Error() string {
return receiver.err.Error()
}
func (internalVariantAlsoNegotiates) ErrHTTP() {
// Nothing here.
func (internalVariantAlsoNegotiates) ErrHTTP() int {
return http.StatusVariantAlsoNegotiates
}
func (internalVariantAlsoNegotiates) ServerError() {