Compare commits

...

10 Commits

72 changed files with 596 additions and 567 deletions

View File

@ -1,11 +1,14 @@
# go-errhttp
Package **errhttp** provides types errors that make dealing with HTTP response errors easier, for the Go programming language.
Package **errhttp** provides errors and types that make dealing with HTTP response errors easier, for the Go programming language.
## Example
Here is an example of wrapping an error:
```go
import "github.com/reiver/go-errhttp"
import "sourcecode.social/reiver/go-errhttp"
// ...
@ -33,8 +36,37 @@ Package **errhttp** provides types errors that make dealing with HTTP response e
}
```
Here is an example of using one of the package global variable errors:
```go
import "sourcecode.social/reiver/go-errhttp"
// ...
return errhttp.ErrBadRequest
// ...
switch err.(type) {
case errhttp.BadRequest:
//@TODO
case errhttp.NotFound:
//@TODO
case errhttp.InternalServerError:
//@TODO
case errhttp.ClientError:
//@TODO
case errhttp.ServerError:
//@TODO
default:
//@TODO
}
```
## Documention
Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-errhttp
Online documentation, which includes examples, can be found at: http://godoc.org/sourcecode.social/reiver/go-errhttp
[![GoDoc](https://godoc.org/github.com/reiver/go-errhttp?status.svg)](https://godoc.org/github.com/reiver/go-errhttp)
[![GoDoc](https://godoc.org/sourcecode.social/reiver/go-errhttp?status.svg)](https://godoc.org/sourcecode.social/reiver/go-errhttp)

View File

@ -1,10 +1,18 @@
package errhttp
var _ Error = internalBadGateway{}
var _ ServerError = internalBadGateway{}
var _ BadGateway = internalBadGateway{}
var ErrBadGateway error = BadGatewayWrap(nil)
type BadGateway interface {
ServerError
BadGateway()
}
var _ BadGateway = internalBadGateway{}
type internalBadGateway struct {
err error
}
@ -19,8 +27,8 @@ func (receiver internalBadGateway) Error() string {
return receiver.err.Error()
}
func (receiver internalBadGateway) Err() error {
return receiver.err
func (internalBadGateway) ErrHTTP() {
// Nothing here.
}
func (internalBadGateway) ServerError() {
@ -30,3 +38,7 @@ func (internalBadGateway) ServerError() {
func (internalBadGateway) BadGateway() {
// Nothing here.
}
func (receiver internalBadGateway) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalBadRequest{}
var _ ClientError = internalBadRequest{}
var _ BadRequest = internalBadRequest{}
var ErrBadRequest = BadRequestWrap(nil)
type BadRequest interface {
ClientError
BadRequest()
@ -19,8 +25,8 @@ func (receiver internalBadRequest) Error() string {
return receiver.err.Error()
}
func (receiver internalBadRequest) Err() error {
return receiver.err
func (internalBadRequest) ErrHTTP() {
// Nothing here.
}
func (internalBadRequest) ClientError() {
@ -30,3 +36,7 @@ func (internalBadRequest) ClientError() {
func (internalBadRequest) BadRequest() {
// Nothing here.
}
func (receiver internalBadRequest) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestBadRequest(t *testing.T) {
var x BadRequest = internalBadRequest{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,42 +0,0 @@
package errhttp
import (
"testing"
)
func TestClientError(t *testing.T) {
var x ClientError
x = internalBadRequest{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalUnauthorized{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalPaymentRequired{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalForbidden{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalNotFound{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalMethodNotAllowed{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalNotAcceptable{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalProxyAuthRequired{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalRequestTimeout{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalConflict{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalGone{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalLengthRequired{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalPreconditionFailed{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalRequestEntityTooLarge{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalRequestURITooLong{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalUnsupportedMediaType{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalRequestedRangeNotSatisfiable{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalExpectationFailed{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalTeapot{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalUnprocessableEntity{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalLocked{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalFailedDependency{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalUpgradeRequired{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalPreconditionRequired{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalTooManyRequests{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalRequestHeaderFieldsTooLarge{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalUnavailableForLegalReasons{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should never happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalConflict{}
var _ ClientError = internalConflict{}
var _ Conflict = internalConflict{}
var ErrConflict = ConflictWrap(nil)
type Conflict interface {
ClientError
Conflict()
@ -19,8 +25,8 @@ func (receiver internalConflict) Error() string {
return receiver.err.Error()
}
func (receiver internalConflict) Err() error {
return receiver.err
func (internalConflict) ErrHTTP() {
// Nothing here.
}
func (internalConflict) ClientError() {
@ -30,3 +36,7 @@ func (internalConflict) ClientError() {
func (internalConflict) Conflict() {
// Nothing here.
}
func (receiver internalConflict) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestConflict(t *testing.T) {
var x Conflict = internalConflict{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

33
doc.go
View File

@ -1,33 +0,0 @@
/*
Package errhttp provides types errors that make dealing with HTTP response errors easier.
Example
import "github.com/reiver/go-errhttp"
// ...
if err := something(); nil != err {
return errhttp.BadRequestWrap(err)
}
// ...
switch err.(type) {
case errhttp.BadRequest:
//@TODO
case errhttp.NotFound:
//@TODO
case errhttp.InternalServerError:
//@TODO
case errhttp.ClientError:
//@TODO
case errhttp.ServerError:
//@TODO
default:
//@TODO
}
*/
package errhttp

View File

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

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalExpectationFailed{}
var _ ClientError = internalExpectationFailed{}
var _ ExpectationFailed = internalExpectationFailed{}
var ErrExpectationFailed error = ExpectationFailedWrap(nil)
type ExpectationFailed interface {
ClientError
ExpectationFailed()
@ -19,8 +25,8 @@ func (receiver internalExpectationFailed) Error() string {
return receiver.err.Error()
}
func (receiver internalExpectationFailed) Err() error {
return receiver.err
func (internalExpectationFailed) ErrHTTP() {
// Nothing here.
}
func (internalExpectationFailed) ClientError() {
@ -30,3 +36,7 @@ func (internalExpectationFailed) ClientError() {
func (internalExpectationFailed) ExpectationFailed() {
// Nothing here.
}
func (receiver internalExpectationFailed) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestExpectationFailed(t *testing.T) {
var x ExpectationFailed = internalExpectationFailed{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalFailedDependency{}
var _ ClientError = internalFailedDependency{}
var _ FailedDependency = internalFailedDependency{}
var ErrFailedDependency error = FailedDependencyWrap(nil)
type FailedDependency interface {
ClientError
FailedDependency()
@ -19,8 +25,8 @@ func (receiver internalFailedDependency) Error() string {
return receiver.err.Error()
}
func (receiver internalFailedDependency) Err() error {
return receiver.err
func (internalFailedDependency) ErrHTTP() {
// Nothing here.
}
func (internalFailedDependency) ClientError() {
@ -31,3 +37,6 @@ func (internalFailedDependency) FailedDependency() {
// Nothing here.
}
func (receiver internalFailedDependency) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestFailedDependency(t *testing.T) {
var x FailedDependency = internalFailedDependency{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalForbidden{}
var _ ClientError = internalForbidden{}
var _ Forbidden = internalForbidden{}
var ErrForbidden error = ForbiddenWrap(nil)
type Forbidden interface {
ClientError
Forbidden()
@ -19,8 +25,8 @@ func (receiver internalForbidden) Error() string {
return receiver.err.Error()
}
func (receiver internalForbidden) Err() error {
return receiver.err
func (internalForbidden) ErrHTTP() {
// Nothing here.
}
func (internalForbidden) ClientError() {
@ -31,3 +37,6 @@ func (internalForbidden) Forbidden() {
// Nothing here.
}
func (receiver internalForbidden) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestForbidden(t *testing.T) {
var x Forbidden = internalForbidden{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,10 +1,18 @@
package errhttp
var _ Error = internalGatewayTimeout{}
var _ ServerError = internalGatewayTimeout{}
var _ GatewayTimeout = internalGatewayTimeout{}
var ErrGatewayTimeout error = GatewayTimeoutWrap(nil)
type GatewayTimeout interface {
ServerError
GatewayTimeout()
}
var _ GatewayTimeout = internalGatewayTimeout{}
type internalGatewayTimeout struct {
err error
}
@ -19,8 +27,8 @@ func (receiver internalGatewayTimeout) Error() string {
return receiver.err.Error()
}
func (receiver internalGatewayTimeout) Err() error {
return receiver.err
func (internalGatewayTimeout) ErrHTTP() {
// Nothing here.
}
func (internalGatewayTimeout) ServerError() {
@ -30,3 +38,7 @@ func (internalGatewayTimeout) ServerError() {
func (internalGatewayTimeout) GatewayTimeout() {
// Nothing here.
}
func (receiver internalGatewayTimeout) Unwrap() error {
return receiver.err
}

13
gone.go
View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalGone{}
var _ ClientError = internalGone{}
var _ Gone = internalGone{}
var ErrGone error = GoneWrap(nil)
type Gone interface {
ClientError()
Gone()
@ -19,8 +25,8 @@ func (receiver internalGone) Error() string {
return receiver.err.Error()
}
func (receiver internalGone) Err() error {
return receiver.err
func (internalGone) ErrHTTP() {
// Nothing here.
}
func (internalGone) ClientError() {
@ -31,3 +37,6 @@ func (internalGone) Gone() {
// Nothing here.
}
func (receiver internalGone) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestGone(t *testing.T) {
var x Gone = internalGone{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,10 +1,18 @@
package errhttp
var _ Error = internalHTTPVersionNotSupported{}
var _ ServerError = internalHTTPVersionNotSupported{}
var _ HTTPVersionNotSupported = internalHTTPVersionNotSupported{}
var ErrHTTPVersionNotSupported error = HTTPVersionNotSupportedWrap(nil)
type HTTPVersionNotSupported interface {
ServerError
HTTPVersionNotSupported()
}
var _ HTTPVersionNotSupported = internalHTTPVersionNotSupported{}
type internalHTTPVersionNotSupported struct {
err error
}
@ -19,8 +27,8 @@ func (receiver internalHTTPVersionNotSupported) Error() string {
return receiver.err.Error()
}
func (receiver internalHTTPVersionNotSupported) Err() error {
return receiver.err
func (internalHTTPVersionNotSupported) ErrHTTP() {
// Nothing here.
}
func (internalHTTPVersionNotSupported) ServerError() {
@ -30,3 +38,7 @@ func (internalHTTPVersionNotSupported) ServerError() {
func (internalHTTPVersionNotSupported) HTTPVersionNotSupported() {
// Nothing here.
}
func (receiver internalHTTPVersionNotSupported) Unwrap() error {
return receiver.err
}

View File

@ -1,10 +1,18 @@
package errhttp
var _ Error = internalInsufficientStorage{}
var _ ServerError = internalInsufficientStorage{}
var _ InsufficientStorage = internalInsufficientStorage{}
var ErrInsufficientStorage error = InsufficientStorageWrap(nil)
type InsufficientStorage interface {
ServerError
InsufficientStorage()
}
var _ InsufficientStorage = internalInsufficientStorage{}
type internalInsufficientStorage struct {
err error
}
@ -19,8 +27,8 @@ func (receiver internalInsufficientStorage) Error() string {
return receiver.err.Error()
}
func (receiver internalInsufficientStorage) Err() error {
return receiver.err
func (internalInsufficientStorage) ErrHTTP() {
// Nothing here.
}
func (internalInsufficientStorage) ServerError() {
@ -30,3 +38,7 @@ func (internalInsufficientStorage) ServerError() {
func (internalInsufficientStorage) InsufficientStorage() {
// Nothing here.
}
func (receiver internalInsufficientStorage) Unwrap() error {
return receiver.err
}

View File

@ -1,10 +1,18 @@
package errhttp
var _ Error = internalInternalServerError{}
var _ ServerError = internalInternalServerError{}
var _ InternalServerError = internalInternalServerError{}
var ErrInternalServerError error = InternalServerErrorWrap(nil)
type InternalServerError interface {
ServerError
InternalServerError()
}
var _ InternalServerError = internalInternalServerError{}
type internalInternalServerError struct {
err error
}
@ -19,8 +27,8 @@ func (receiver internalInternalServerError) Error() string {
return receiver.err.Error()
}
func (receiver internalInternalServerError) Err() error {
return receiver.err
func (internalInternalServerError) ErrHTTP() {
// Nothing here.
}
func (internalInternalServerError) ServerError() {
@ -30,3 +38,7 @@ func (internalInternalServerError) ServerError() {
func (internalInternalServerError) InternalServerError() {
// Nothing here.
}
func (receiver internalInternalServerError) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalLengthRequired{}
var _ ClientError = internalLengthRequired{}
var _ LengthRequired = internalLengthRequired{}
var ErrLengthRequired error = LengthRequiredWrap(nil)
type LengthRequired interface {
ClientError
LengthRequired()
@ -19,8 +25,8 @@ func (receiver internalLengthRequired) Error() string {
return receiver.err.Error()
}
func (receiver internalLengthRequired) Err() error {
return receiver.err
func (internalLengthRequired) ErrHTTP() {
// Nothing here.
}
func (internalLengthRequired) ClientError() {
@ -31,3 +37,6 @@ func (internalLengthRequired) LengthRequired() {
// Nothing here.
}
func (receiver internalLengthRequired) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestLengthRequired(t *testing.T) {
var x LengthRequired = internalLengthRequired{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalLocked{}
var _ ClientError = internalLocked{}
var _ Locked = internalLocked{}
var ErrLocked error = LockedWrap(nil)
type Locked interface {
ClientError
Locked()
@ -19,8 +25,8 @@ func (receiver internalLocked) Error() string {
return receiver.err.Error()
}
func (receiver internalLocked) Err() error {
return receiver.err
func (internalLocked) ErrHTTP() {
// Nothing here.
}
func (internalLocked) ClientError() {
@ -30,3 +36,7 @@ func (internalLocked) ClientError() {
func (internalLocked) Locked() {
// Nothing here.
}
func (receiver internalLocked) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestLocked(t *testing.T) {
var x Locked = internalLocked{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,10 +1,18 @@
package errhttp
var _ Error = internalLoopDetected{}
var _ ServerError = internalLoopDetected{}
var _ LoopDetected = internalLoopDetected{}
var ErrLoopDetected error = LoopDetectedWrap(nil)
type LoopDetected interface {
ServerError
LoopDetected()
}
var _ LoopDetected = internalLoopDetected{}
type internalLoopDetected struct {
err error
}
@ -19,8 +27,8 @@ func (receiver internalLoopDetected) Error() string {
return receiver.err.Error()
}
func (receiver internalLoopDetected) Err() error {
return receiver.err
func (internalLoopDetected) ErrHTTP() {
// Nothing here.
}
func (internalLoopDetected) ServerError() {
@ -30,3 +38,7 @@ func (internalLoopDetected) ServerError() {
func (internalLoopDetected) LoopDetected() {
// Nothing here.
}
func (receiver internalLoopDetected) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalMethodNotAllowed{}
var _ ClientError = internalMethodNotAllowed{}
var _ MethodNotAllowed = internalMethodNotAllowed{}
var ErrMethodNotAllowed error = MethodNotAllowedWrap(nil)
type MethodNotAllowed interface {
ClientError
MethodNotAllowed()
@ -19,8 +25,8 @@ func (receiver internalMethodNotAllowed) Error() string {
return receiver.err.Error()
}
func (receiver internalMethodNotAllowed) Err() error {
return receiver.err
func (internalMethodNotAllowed) ErrHTTP() {
// Nothing here.
}
func (internalMethodNotAllowed) ClientError() {
@ -31,3 +37,6 @@ func (internalMethodNotAllowed) MethodNotAllowed() {
// Nothing here.
}
func (receiver internalMethodNotAllowed) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestMethodNotAllowed(t *testing.T) {
var x MethodNotAllowed = internalMethodNotAllowed{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,10 +1,18 @@
package errhttp
var _ Error = internalNetworkAuthenticationRequired{}
var _ ServerError = internalNetworkAuthenticationRequired{}
var _ NetworkAuthenticationRequired = internalNetworkAuthenticationRequired{}
var ErrNetworkAuthenticationRequired error = NetworkAuthenticationRequiredWrap(nil)
type NetworkAuthenticationRequired interface {
ServerError
NetworkAuthenticationRequired()
}
var _ NetworkAuthenticationRequired = internalNetworkAuthenticationRequired{}
type internalNetworkAuthenticationRequired struct {
err error
}
@ -19,8 +27,8 @@ func (receiver internalNetworkAuthenticationRequired) Error() string {
return receiver.err.Error()
}
func (receiver internalNetworkAuthenticationRequired) Err() error {
return receiver.err
func (internalNetworkAuthenticationRequired) ErrHTTP() {
// Nothing here.
}
func (internalNetworkAuthenticationRequired) ServerError() {
@ -30,3 +38,7 @@ func (internalNetworkAuthenticationRequired) ServerError() {
func (internalNetworkAuthenticationRequired) NetworkAuthenticationRequired() {
// Nothing here.
}
func (receiver internalNetworkAuthenticationRequired) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalNotAcceptable{}
var _ ClientError = internalNotAcceptable{}
var _ NotAcceptable = internalNotAcceptable{}
var ErrNotAcceptable error = NotAcceptableWrap(nil)
type NotAcceptable interface {
ClientError
NotAcceptable()
@ -19,8 +25,8 @@ func (receiver internalNotAcceptable) Error() string {
return receiver.err.Error()
}
func (receiver internalNotAcceptable) Err() error {
return receiver.err
func (internalNotAcceptable) ErrHTTP() {
// Nothing here.
}
func (internalNotAcceptable) ClientError() {
@ -30,3 +36,7 @@ func (internalNotAcceptable) ClientError() {
func (internalNotAcceptable) NotAcceptable() {
// Nothing here.
}
func (receiver internalNotAcceptable) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestNotAcceptable(t *testing.T) {
var x NotAcceptable = internalNotAcceptable{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,10 +1,18 @@
package errhttp
var _ Error = internalNotExtended{}
var _ ServerError = internalNotExtended{}
var _ NotExtended = internalNotExtended{}
var ErrNotExtended error = NotExtendedWrap(nil)
type NotExtended interface {
ServerError
NotExtended()
}
var _ NotExtended = internalNotExtended{}
type internalNotExtended struct {
err error
}
@ -19,8 +27,8 @@ func (receiver internalNotExtended) Error() string {
return receiver.err.Error()
}
func (receiver internalNotExtended) Err() error {
return receiver.err
func (internalNotExtended) ErrHTTP() {
// Nothing here.
}
func (internalNotExtended) ServerError() {
@ -30,3 +38,7 @@ func (internalNotExtended) ServerError() {
func (internalNotExtended) NotExtended() {
// Nothing here.
}
func (receiver internalNotExtended) Unwrap() error {
return receiver.err
}

View File

@ -1,11 +1,17 @@
package errhttp
var _ Error = internalNotFound{}
var _ ClientError = internalNotFound{}
var _ NotFound = internalNotFound{}
var ErrNotFound error = NotFoundWrap(nil)
type NotFound interface {
ClientError
NotFound ()
}
type internalNotFound struct {
type internalNotFound struct {
err error
}
@ -19,8 +25,8 @@ func (receiver internalNotFound ) Error() string {
return receiver.err.Error()
}
func (receiver internalNotFound ) Err() error {
return receiver.err
func (internalNotFound ) ErrHTTP() {
// Nothing here.
}
func (internalNotFound ) ClientError() {
@ -30,3 +36,7 @@ func (internalNotFound ) ClientError() {
func (internalNotFound ) NotFound() {
// Nothing here.
}
func (receiver internalNotFound) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestNotFound(t *testing.T) {
var x NotFound = internalNotFound{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,10 +1,18 @@
package errhttp
var _ Error = internalNotImplemented{}
var _ ServerError = internalNotImplemented{}
var _ NotImplemented = internalNotImplemented{}
var ErrNotImplemented error = NotImplementedWrap(nil)
type NotImplemented interface {
ServerError
NotImplemented()
}
var _ NotImplemented = internalNotImplemented{}
type internalNotImplemented struct {
err error
}
@ -19,8 +27,8 @@ func (receiver internalNotImplemented) Error() string {
return receiver.err.Error()
}
func (receiver internalNotImplemented) Err() error {
return receiver.err
func (internalNotImplemented) ErrHTTP() {
// Nothing here.
}
func (internalNotImplemented) ServerError() {
@ -30,3 +38,7 @@ func (internalNotImplemented) ServerError() {
func (internalNotImplemented) NotImplemented() {
// Nothing here.
}
func (receiver internalNotImplemented) Unwrap() error {
return receiver.err
}

42
payloadtoolarge.go 100644
View File

@ -0,0 +1,42 @@
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,11 @@
package errhttp
var _ Error = internalPaymentRequired{}
var _ ClientError = internalPaymentRequired{}
var _ PaymentRequired = internalPaymentRequired{}
var ErrPaymentRequired error = PaymentRequiredWrap(nil)
type PaymentRequired interface {
ClientError
PaymentRequired()
@ -19,10 +25,11 @@ func (receiver internalPaymentRequired) Error() string {
return receiver.err.Error()
}
func (receiver internalPaymentRequired) Err() error {
return receiver.err
func (internalPaymentRequired) ErrHTTP() {
// Nothing here.
}
func (internalPaymentRequired) ClientError() {
// Nothing here.
}
@ -30,3 +37,7 @@ func (internalPaymentRequired) ClientError() {
func (internalPaymentRequired) PaymentRequired() {
// Nothing here.
}
func (receiver internalPaymentRequired) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestPaymentRequired(t *testing.T) {
var x PaymentRequired = internalPaymentRequired{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalPreconditionFailed{}
var _ ClientError = internalPreconditionFailed{}
var _ PreconditionFailed = internalPreconditionFailed{}
var ErrPreconditionFailed error = PreconditionFailedWrap(nil)
type PreconditionFailed interface {
ClientError
PreconditionFailed()
@ -19,8 +25,8 @@ func (receiver internalPreconditionFailed) Error() string {
return receiver.err.Error()
}
func (receiver internalPreconditionFailed) Err() error {
return receiver.err
func (internalPreconditionFailed) ErrHTTP() {
// Nothing here.
}
func (internalPreconditionFailed) ClientError() {
@ -30,3 +36,7 @@ func (internalPreconditionFailed) ClientError() {
func (internalPreconditionFailed) PreconditionFailed() {
// Nothing here.
}
func (receiver internalPreconditionFailed) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestPreconditionFailed(t *testing.T) {
var x PreconditionFailed = internalPreconditionFailed{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalPreconditionRequired{}
var _ ClientError = internalPreconditionRequired{}
var _ PreconditionRequired = internalPreconditionRequired{}
var ErrPreconditionRequired error = PreconditionRequiredWrap(nil)
type PreconditionRequired interface {
ClientError
PreconditionRequired()
@ -19,8 +25,8 @@ func (receiver internalPreconditionRequired) Error() string {
return receiver.err.Error()
}
func (receiver internalPreconditionRequired) Err() error {
return receiver.err
func (internalPreconditionRequired) ErrHTTP() {
// Nothing here.
}
func (internalPreconditionRequired) ClientError() {
@ -31,3 +37,6 @@ func (internalPreconditionRequired) PreconditionRequired() {
// Nothing here.
}
func (receiver internalPreconditionRequired) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestPreconditionRequired(t *testing.T) {
var x PreconditionRequired = internalPreconditionRequired{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalProxyAuthRequired{}
var _ ClientError = internalProxyAuthRequired{}
var _ ProxyAuthRequired = internalProxyAuthRequired{}
var ErrProxyAuthRequired error = ProxyAuthRequiredWrap(nil)
type ProxyAuthRequired interface {
ClientError
ProxyAuthRequired()
@ -19,8 +25,8 @@ func (receiver internalProxyAuthRequired) Error() string {
return receiver.err.Error()
}
func (receiver internalProxyAuthRequired) Err() error {
return receiver.err
func (internalProxyAuthRequired) ErrHTTP() {
// Nothing here.
}
func (internalProxyAuthRequired) ClientError() {
@ -30,3 +36,7 @@ func (internalProxyAuthRequired) ClientError() {
func (internalProxyAuthRequired) ProxyAuthRequired() {
// Nothing here.
}
func (receiver internalProxyAuthRequired) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestProxyAuthRequired(t *testing.T) {
var x ProxyAuthRequired = internalProxyAuthRequired{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalRequestedRangeNotSatisfiable{}
var _ ClientError = internalRequestedRangeNotSatisfiable{}
var _ RequestedRangeNotSatisfiable = internalRequestedRangeNotSatisfiable{}
var ErrRequestedRangeNotSatisfiable error = RequestedRangeNotSatisfiableWrap(nil)
type RequestedRangeNotSatisfiable interface {
ClientError
RequestedRangeNotSatisfiable()
@ -19,8 +25,8 @@ func (receiver internalRequestedRangeNotSatisfiable) Error() string {
return receiver.err.Error()
}
func (receiver internalRequestedRangeNotSatisfiable) Err() error {
return receiver.err
func (internalRequestedRangeNotSatisfiable) ErrHTTP() {
// Nothing here.
}
func (internalRequestedRangeNotSatisfiable) ClientError() {
@ -30,3 +36,7 @@ func (internalRequestedRangeNotSatisfiable) ClientError() {
func (internalRequestedRangeNotSatisfiable) RequestedRangeNotSatisfiable() {
// Nothing here.
}
func (receiver internalRequestedRangeNotSatisfiable) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestRequestedRangeNotSatisfiable(t *testing.T) {
var x RequestedRangeNotSatisfiable = internalRequestedRangeNotSatisfiable{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalRequestEntityTooLarge{}
var _ ClientError = internalRequestEntityTooLarge{}
var _ RequestEntityTooLarge = internalRequestEntityTooLarge{}
var ErrRequestEntityTooLarge error = RequestEntityTooLargeWrap(nil)
type RequestEntityTooLarge interface {
ClientError
RequestEntityTooLarge()
@ -19,8 +25,8 @@ func (receiver internalRequestEntityTooLarge) Error() string {
return receiver.err.Error()
}
func (receiver internalRequestEntityTooLarge) Err() error {
return receiver.err
func (internalRequestEntityTooLarge) ErrHTTP() {
// Nothing here.
}
func (internalRequestEntityTooLarge) ClientError() {
@ -30,3 +36,7 @@ func (internalRequestEntityTooLarge) ClientError() {
func (internalRequestEntityTooLarge) RequestEntityTooLarge() {
// Nothing here.
}
func (receiver internalRequestEntityTooLarge) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestRequestEntityTooLarge(t *testing.T) {
var x RequestEntityTooLarge = internalRequestEntityTooLarge{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,8 +1,13 @@
package errhttp
var _ Error = internalRequestHeaderFieldsTooLarge{}
var _ ClientError = internalRequestHeaderFieldsTooLarge{}
var _ RequestHeaderFieldsTooLarge = internalRequestHeaderFieldsTooLarge{}
var ErrRequestHeaderFieldsTooLarge error = RequestHeaderFieldsTooLargeWrap(nil)
type RequestHeaderFieldsTooLarge interface {
error
Err() error
ClientError
RequestHeaderFieldsTooLarge()
}
@ -20,8 +25,8 @@ func (receiver internalRequestHeaderFieldsTooLarge) Error() string {
return receiver.err.Error()
}
func (receiver internalRequestHeaderFieldsTooLarge) Err() error {
return receiver.err
func (internalRequestHeaderFieldsTooLarge) ErrHTTP() {
// Nothing here.
}
func (internalRequestHeaderFieldsTooLarge) ClientError() {
@ -31,3 +36,7 @@ func (internalRequestHeaderFieldsTooLarge) ClientError() {
func (internalRequestHeaderFieldsTooLarge) RequestHeaderFieldsTooLarge() {
// Nothing here.
}
func (receiver internalRequestHeaderFieldsTooLarge) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestRequestHeaderFieldsTooLarge(t *testing.T) {
var x RequestHeaderFieldsTooLarge = internalRequestHeaderFieldsTooLarge{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,8 +1,13 @@
package errhttp
var _ Error = internalRequestTimeout{}
var _ ClientError = internalRequestTimeout{}
var _ RequestTimeout = internalRequestTimeout{}
var ErrRequestTimeout error = RequestTimeoutWrap(nil)
type RequestTimeout interface {
error
Err() error
ClientError
RequestTimeout()
}
@ -20,8 +25,8 @@ func (receiver internalRequestTimeout) Error() string {
return receiver.err.Error()
}
func (receiver internalRequestTimeout) Err() error {
return receiver.err
func (internalRequestTimeout) ErrHTTP() {
// Nothing here.
}
func (internalRequestTimeout) ClientError() {
@ -31,3 +36,7 @@ func (internalRequestTimeout) ClientError() {
func (internalRequestTimeout) RequestTimeout() {
// Nothing here.
}
func (receiver internalRequestTimeout) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestRequestTimeout(t *testing.T) {
var x RequestTimeout = internalRequestTimeout{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,8 +1,13 @@
package errhttp
var _ Error = internalRequestURITooLong{}
var _ ClientError = internalRequestURITooLong{}
var _ RequestURITooLong = internalRequestURITooLong{}
var ErrRequestURITooLong error = RequestURITooLongWrap(nil)
type RequestURITooLong interface {
error
Err() error
ClientError
RequestURITooLong()
}
@ -20,8 +25,8 @@ func (receiver internalRequestURITooLong) Error() string {
return receiver.err.Error()
}
func (receiver internalRequestURITooLong) Err() error {
return receiver.err
func (internalRequestURITooLong) ErrHTTP() {
// Nothing here.
}
func (internalRequestURITooLong) ClientError() {
@ -31,3 +36,7 @@ func (internalRequestURITooLong) ClientError() {
func (internalRequestURITooLong) RequestURITooLong() {
// Nothing here.
}
func (receiver internalRequestURITooLong) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestRequestURITooLong(t *testing.T) {
var x RequestURITooLong = internalRequestURITooLong{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,26 +0,0 @@
package errhttp
import (
"testing"
)
func TestServerError(t *testing.T) {
var x ServerError
x = internalInternalServerError{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalNotImplemented{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalBadGateway{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalServiceUnavailable{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalGatewayTimeout{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalHTTPVersionNotSupported{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalVariantAlsoNegotiates{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalInsufficientStorage{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalLoopDetected{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalNotExtended{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
x = internalNetworkAuthenticationRequired{} // THESE ARE THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should never happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalServiceUnavailable{}
var _ ServerError = internalServiceUnavailable{}
var _ ServiceUnavailable = internalServiceUnavailable{}
var ErrServiceUnavailable error = ServiceUnavailableWrap(nil)
type ServiceUnavailable interface {
ServerError
ServiceUnavailable()
@ -19,8 +25,8 @@ func (receiver internalServiceUnavailable) Error() string {
return receiver.err.Error()
}
func (receiver internalServiceUnavailable) Err() error {
return receiver.err
func (internalServiceUnavailable) ErrHTTP() {
// Nothing here.
}
func (internalServiceUnavailable) ServerError() {
@ -30,3 +36,7 @@ func (internalServiceUnavailable) ServerError() {
func (internalServiceUnavailable) ServiceUnavailable() {
// Nothing here.
}
func (receiver internalServiceUnavailable) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalTeapot{}
var _ ClientError = internalTeapot{}
var _ Teapot = internalTeapot{}
var ErrTeapot error = TeapotWrap(nil)
type Teapot interface {
ClientError
Teapot()
@ -19,8 +25,8 @@ func (receiver internalTeapot) Error() string {
return receiver.err.Error()
}
func (receiver internalTeapot) Err() error {
return receiver.err
func (internalTeapot) ErrHTTP() {
// Nothing here.
}
func (internalTeapot) ClientError() {
@ -30,3 +36,7 @@ func (internalTeapot) ClientError() {
func (internalTeapot) Teapot() {
// Nothing here.
}
func (receiver internalTeapot) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestTeapot(t *testing.T) {
var x Teapot = internalTeapot{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalTooManyRequests{}
var _ ClientError = internalTooManyRequests{}
var _ TooManyRequests = internalTooManyRequests{}
var ErrTooManyRequests error = TooManyRequestsWrap(nil)
type TooManyRequests interface {
ClientError
TooManyRequests()
@ -19,8 +25,8 @@ func (receiver internalTooManyRequests) Error() string {
return receiver.err.Error()
}
func (receiver internalTooManyRequests) Err() error {
return receiver.err
func (internalTooManyRequests) ErrHTTP() {
// Nothing here.
}
func (internalTooManyRequests) ClientError() {
@ -30,3 +36,7 @@ func (internalTooManyRequests) ClientError() {
func (internalTooManyRequests) TooManyRequests() {
// Nothing here.
}
func (receiver internalTooManyRequests) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestTooManyRequests(t *testing.T) {
var x TooManyRequests = internalTooManyRequests{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalUnauthorized{}
var _ ClientError = internalUnauthorized{}
var _ Unauthorized = internalUnauthorized{}
var ErrUnauthorized error = UnauthorizedWrap(nil)
type Unauthorized interface {
ClientError
Unauthorized()
@ -19,8 +25,8 @@ func (receiver internalUnauthorized) Error() string {
return receiver.err.Error()
}
func (receiver internalUnauthorized) Err() error {
return receiver.err
func (internalUnauthorized) ErrHTTP() {
// Nothing here.
}
func (internalUnauthorized) ClientError() {
@ -30,3 +36,7 @@ func (internalUnauthorized) ClientError() {
func (internalUnauthorized) Unauthorized() {
// Nothing here.
}
func (receiver internalUnauthorized) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestUnauthorized(t *testing.T) {
var x Unauthorized = internalUnauthorized{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalUnavailableForLegalReasons{}
var _ ClientError = internalUnavailableForLegalReasons{}
var _ UnavailableForLegalReasons = internalUnavailableForLegalReasons{}
var ErrUnavailableForLegalReasons error = UnavailableForLegalReasonsWrap(nil)
type UnavailableForLegalReasons interface {
ClientError
UnavailableForLegalReasons()
@ -19,8 +25,8 @@ func (receiver internalUnavailableForLegalReasons) Error() string {
return receiver.err.Error()
}
func (receiver internalUnavailableForLegalReasons) Err() error {
return receiver.err
func (internalUnavailableForLegalReasons) ErrHTTP() {
// Nothing here.
}
func (internalUnavailableForLegalReasons) ClientError() {
@ -31,3 +37,6 @@ func (internalUnavailableForLegalReasons) UnavailableForLegalReasons() {
// Nothing here.
}
func (receiver internalUnavailableForLegalReasons) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestUnavailableForLegalReasons(t *testing.T) {
var x UnavailableForLegalReasons = internalUnavailableForLegalReasons{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalUnprocessableEntity{}
var _ ClientError = internalUnprocessableEntity{}
var _ UnprocessableEntity = internalUnprocessableEntity{}
var ErrUnprocessableEntity error = UnprocessableEntityWrap(nil)
type UnprocessableEntity interface {
ClientError
UnprocessableEntity()
@ -19,8 +25,8 @@ func (receiver internalUnprocessableEntity) Error() string {
return receiver.err.Error()
}
func (receiver internalUnprocessableEntity) Err() error {
return receiver.err
func (internalUnprocessableEntity) ErrHTTP() {
// Nothing here.
}
func (internalUnprocessableEntity) ClientError() {
@ -30,3 +36,7 @@ func (internalUnprocessableEntity) ClientError() {
func (internalUnprocessableEntity) UnprocessableEntity() {
// Nothing here.
}
func (receiver internalUnprocessableEntity) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestUnprocessableEntity(t *testing.T) {
var x UnprocessableEntity = internalUnprocessableEntity{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalUnsupportedMediaType{}
var _ ClientError = internalUnsupportedMediaType{}
var _ UnsupportedMediaType = internalUnsupportedMediaType{}
var ErrUnsupportedMediaType error = UnsupportedMediaTypeWrap(nil)
type UnsupportedMediaType interface {
ClientError
UnsupportedMediaType()
@ -19,8 +25,8 @@ func (receiver internalUnsupportedMediaType) Error() string {
return receiver.err.Error()
}
func (receiver internalUnsupportedMediaType) Err() error {
return receiver.err
func (internalUnsupportedMediaType) ErrHTTP() {
// Nothing here.
}
func (internalUnsupportedMediaType) ClientError() {
@ -30,3 +36,7 @@ func (internalUnsupportedMediaType) ClientError() {
func (internalUnsupportedMediaType) UnsupportedMediaType() {
// Nothing here.
}
func (receiver internalUnsupportedMediaType) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestUnsupportedMediaType(t *testing.T) {
var x UnsupportedMediaType = internalUnsupportedMediaType{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

View File

@ -1,5 +1,11 @@
package errhttp
var _ Error = internalUpgradeRequired{}
var _ ClientError = internalUpgradeRequired{}
var _ UpgradeRequired = internalUpgradeRequired{}
var ErrUpgradeRequired error = UpgradeRequiredWrap(nil)
type UpgradeRequired interface {
ClientError
UpgradeRequired()
@ -19,8 +25,8 @@ func (receiver internalUpgradeRequired) Error() string {
return receiver.err.Error()
}
func (receiver internalUpgradeRequired) Err() error {
return receiver.err
func (internalUpgradeRequired) ErrHTTP() {
// Nothing here.
}
func (internalUpgradeRequired) ClientError() {
@ -30,3 +36,7 @@ func (internalUpgradeRequired) ClientError() {
func (internalUpgradeRequired) UpgradeRequired() {
// Nothing here.
}
func (receiver internalUpgradeRequired) Unwrap() error {
return receiver.err
}

View File

@ -1,14 +0,0 @@
package errhttp
import (
"testing"
)
func TestUpgradeRequired(t *testing.T) {
var x UpgradeRequired = internalUpgradeRequired{} // THIS IS THE LINE THAT ACTUALLY MATTERS IN THIS TEST.
if nil == x {
t.Errorf("This should not happen.")
}
}

42
uritoolong.go 100644
View File

@ -0,0 +1,42 @@
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,10 +1,18 @@
package errhttp
var _ Error = internalVariantAlsoNegotiates{}
var _ ServerError = internalVariantAlsoNegotiates{}
var _ VariantAlsoNegotiates = internalVariantAlsoNegotiates{}
var ErrVariantAlsoNegotiates error = VariantAlsoNegotiatesWrap(nil)
type VariantAlsoNegotiates interface {
ServerError
VariantAlsoNegotiates()
}
var _ VariantAlsoNegotiates = internalVariantAlsoNegotiates{}
type internalVariantAlsoNegotiates struct {
err error
}
@ -19,8 +27,8 @@ func (receiver internalVariantAlsoNegotiates) Error() string {
return receiver.err.Error()
}
func (receiver internalVariantAlsoNegotiates) Err() error {
return receiver.err
func (internalVariantAlsoNegotiates) ErrHTTP() {
// Nothing here.
}
func (internalVariantAlsoNegotiates) ServerError() {
@ -30,3 +38,7 @@ func (internalVariantAlsoNegotiates) ServerError() {
func (internalVariantAlsoNegotiates) VariantAlsoNegotiates() {
// Nothing here.
}
func (receiver internalVariantAlsoNegotiates) Unwrap() error {
return receiver.err
}