Compare commits

..

10 Commits

72 changed files with 596 additions and 567 deletions

View File

@ -1,11 +1,14 @@
# go-errhttp # 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 ## Example
Here is an example of wrapping an error:
```go ```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 ## 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 package errhttp
var _ Error = internalBadGateway{}
var _ ServerError = internalBadGateway{}
var _ BadGateway = internalBadGateway{}
var ErrBadGateway error = BadGatewayWrap(nil)
type BadGateway interface { type BadGateway interface {
ServerError ServerError
BadGateway() BadGateway()
} }
var _ BadGateway = internalBadGateway{}
type internalBadGateway struct { type internalBadGateway struct {
err error err error
} }
@ -19,8 +27,8 @@ func (receiver internalBadGateway) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalBadGateway) Err() error { func (internalBadGateway) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalBadGateway) ServerError() { func (internalBadGateway) ServerError() {
@ -30,3 +38,7 @@ func (internalBadGateway) ServerError() {
func (internalBadGateway) BadGateway() { func (internalBadGateway) BadGateway() {
// Nothing here. // Nothing here.
} }
func (receiver internalBadGateway) Unwrap() error {
return receiver.err
}

View File

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

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
var _ Error = internalExpectationFailed{}
var _ ClientError = internalExpectationFailed{}
var _ ExpectationFailed = internalExpectationFailed{}
var ErrExpectationFailed error = ExpectationFailedWrap(nil)
type ExpectationFailed interface { type ExpectationFailed interface {
ClientError ClientError
ExpectationFailed() ExpectationFailed()
@ -19,8 +25,8 @@ func (receiver internalExpectationFailed) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalExpectationFailed) Err() error { func (internalExpectationFailed) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalExpectationFailed) ClientError() { func (internalExpectationFailed) ClientError() {
@ -30,3 +36,7 @@ func (internalExpectationFailed) ClientError() {
func (internalExpectationFailed) ExpectationFailed() { func (internalExpectationFailed) ExpectationFailed() {
// Nothing here. // 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 package errhttp
var _ Error = internalFailedDependency{}
var _ ClientError = internalFailedDependency{}
var _ FailedDependency = internalFailedDependency{}
var ErrFailedDependency error = FailedDependencyWrap(nil)
type FailedDependency interface { type FailedDependency interface {
ClientError ClientError
FailedDependency() FailedDependency()
@ -19,8 +25,8 @@ func (receiver internalFailedDependency) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalFailedDependency) Err() error { func (internalFailedDependency) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalFailedDependency) ClientError() { func (internalFailedDependency) ClientError() {
@ -31,3 +37,6 @@ func (internalFailedDependency) FailedDependency() {
// Nothing here. // 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 package errhttp
var _ Error = internalForbidden{}
var _ ClientError = internalForbidden{}
var _ Forbidden = internalForbidden{}
var ErrForbidden error = ForbiddenWrap(nil)
type Forbidden interface { type Forbidden interface {
ClientError ClientError
Forbidden() Forbidden()
@ -19,8 +25,8 @@ func (receiver internalForbidden) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalForbidden) Err() error { func (internalForbidden) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalForbidden) ClientError() { func (internalForbidden) ClientError() {
@ -31,3 +37,6 @@ func (internalForbidden) Forbidden() {
// Nothing here. // 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 package errhttp
var _ Error = internalGatewayTimeout{}
var _ ServerError = internalGatewayTimeout{}
var _ GatewayTimeout = internalGatewayTimeout{}
var ErrGatewayTimeout error = GatewayTimeoutWrap(nil)
type GatewayTimeout interface { type GatewayTimeout interface {
ServerError ServerError
GatewayTimeout() GatewayTimeout()
} }
var _ GatewayTimeout = internalGatewayTimeout{}
type internalGatewayTimeout struct { type internalGatewayTimeout struct {
err error err error
} }
@ -19,8 +27,8 @@ func (receiver internalGatewayTimeout) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalGatewayTimeout) Err() error { func (internalGatewayTimeout) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalGatewayTimeout) ServerError() { func (internalGatewayTimeout) ServerError() {
@ -30,3 +38,7 @@ func (internalGatewayTimeout) ServerError() {
func (internalGatewayTimeout) GatewayTimeout() { func (internalGatewayTimeout) GatewayTimeout() {
// Nothing here. // Nothing here.
} }
func (receiver internalGatewayTimeout) Unwrap() error {
return receiver.err
}

13
gone.go
View File

@ -1,5 +1,11 @@
package errhttp package errhttp
var _ Error = internalGone{}
var _ ClientError = internalGone{}
var _ Gone = internalGone{}
var ErrGone error = GoneWrap(nil)
type Gone interface { type Gone interface {
ClientError() ClientError()
Gone() Gone()
@ -19,8 +25,8 @@ func (receiver internalGone) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalGone) Err() error { func (internalGone) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalGone) ClientError() { func (internalGone) ClientError() {
@ -31,3 +37,6 @@ func (internalGone) Gone() {
// Nothing here. // 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 package errhttp
var _ Error = internalHTTPVersionNotSupported{}
var _ ServerError = internalHTTPVersionNotSupported{}
var _ HTTPVersionNotSupported = internalHTTPVersionNotSupported{}
var ErrHTTPVersionNotSupported error = HTTPVersionNotSupportedWrap(nil)
type HTTPVersionNotSupported interface { type HTTPVersionNotSupported interface {
ServerError ServerError
HTTPVersionNotSupported() HTTPVersionNotSupported()
} }
var _ HTTPVersionNotSupported = internalHTTPVersionNotSupported{}
type internalHTTPVersionNotSupported struct { type internalHTTPVersionNotSupported struct {
err error err error
} }
@ -19,8 +27,8 @@ func (receiver internalHTTPVersionNotSupported) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalHTTPVersionNotSupported) Err() error { func (internalHTTPVersionNotSupported) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalHTTPVersionNotSupported) ServerError() { func (internalHTTPVersionNotSupported) ServerError() {
@ -30,3 +38,7 @@ func (internalHTTPVersionNotSupported) ServerError() {
func (internalHTTPVersionNotSupported) HTTPVersionNotSupported() { func (internalHTTPVersionNotSupported) HTTPVersionNotSupported() {
// Nothing here. // Nothing here.
} }
func (receiver internalHTTPVersionNotSupported) Unwrap() error {
return receiver.err
}

View File

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

View File

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

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
var _ Error = internalLengthRequired{}
var _ ClientError = internalLengthRequired{}
var _ LengthRequired = internalLengthRequired{}
var ErrLengthRequired error = LengthRequiredWrap(nil)
type LengthRequired interface { type LengthRequired interface {
ClientError ClientError
LengthRequired() LengthRequired()
@ -19,8 +25,8 @@ func (receiver internalLengthRequired) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalLengthRequired) Err() error { func (internalLengthRequired) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalLengthRequired) ClientError() { func (internalLengthRequired) ClientError() {
@ -31,3 +37,6 @@ func (internalLengthRequired) LengthRequired() {
// Nothing here. // 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 package errhttp
var _ Error = internalLocked{}
var _ ClientError = internalLocked{}
var _ Locked = internalLocked{}
var ErrLocked error = LockedWrap(nil)
type Locked interface { type Locked interface {
ClientError ClientError
Locked() Locked()
@ -19,8 +25,8 @@ func (receiver internalLocked) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalLocked) Err() error { func (internalLocked) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalLocked) ClientError() { func (internalLocked) ClientError() {
@ -30,3 +36,7 @@ func (internalLocked) ClientError() {
func (internalLocked) Locked() { func (internalLocked) Locked() {
// Nothing here. // 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 package errhttp
var _ Error = internalLoopDetected{}
var _ ServerError = internalLoopDetected{}
var _ LoopDetected = internalLoopDetected{}
var ErrLoopDetected error = LoopDetectedWrap(nil)
type LoopDetected interface { type LoopDetected interface {
ServerError ServerError
LoopDetected() LoopDetected()
} }
var _ LoopDetected = internalLoopDetected{}
type internalLoopDetected struct { type internalLoopDetected struct {
err error err error
} }
@ -19,8 +27,8 @@ func (receiver internalLoopDetected) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalLoopDetected) Err() error { func (internalLoopDetected) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalLoopDetected) ServerError() { func (internalLoopDetected) ServerError() {
@ -30,3 +38,7 @@ func (internalLoopDetected) ServerError() {
func (internalLoopDetected) LoopDetected() { func (internalLoopDetected) LoopDetected() {
// Nothing here. // Nothing here.
} }
func (receiver internalLoopDetected) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
var _ Error = internalMethodNotAllowed{}
var _ ClientError = internalMethodNotAllowed{}
var _ MethodNotAllowed = internalMethodNotAllowed{}
var ErrMethodNotAllowed error = MethodNotAllowedWrap(nil)
type MethodNotAllowed interface { type MethodNotAllowed interface {
ClientError ClientError
MethodNotAllowed() MethodNotAllowed()
@ -19,8 +25,8 @@ func (receiver internalMethodNotAllowed) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalMethodNotAllowed) Err() error { func (internalMethodNotAllowed) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalMethodNotAllowed) ClientError() { func (internalMethodNotAllowed) ClientError() {
@ -31,3 +37,6 @@ func (internalMethodNotAllowed) MethodNotAllowed() {
// Nothing here. // 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 package errhttp
var _ Error = internalNetworkAuthenticationRequired{}
var _ ServerError = internalNetworkAuthenticationRequired{}
var _ NetworkAuthenticationRequired = internalNetworkAuthenticationRequired{}
var ErrNetworkAuthenticationRequired error = NetworkAuthenticationRequiredWrap(nil)
type NetworkAuthenticationRequired interface { type NetworkAuthenticationRequired interface {
ServerError ServerError
NetworkAuthenticationRequired() NetworkAuthenticationRequired()
} }
var _ NetworkAuthenticationRequired = internalNetworkAuthenticationRequired{}
type internalNetworkAuthenticationRequired struct { type internalNetworkAuthenticationRequired struct {
err error err error
} }
@ -19,8 +27,8 @@ func (receiver internalNetworkAuthenticationRequired) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalNetworkAuthenticationRequired) Err() error { func (internalNetworkAuthenticationRequired) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalNetworkAuthenticationRequired) ServerError() { func (internalNetworkAuthenticationRequired) ServerError() {
@ -30,3 +38,7 @@ func (internalNetworkAuthenticationRequired) ServerError() {
func (internalNetworkAuthenticationRequired) NetworkAuthenticationRequired() { func (internalNetworkAuthenticationRequired) NetworkAuthenticationRequired() {
// Nothing here. // Nothing here.
} }
func (receiver internalNetworkAuthenticationRequired) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
var _ Error = internalNotAcceptable{}
var _ ClientError = internalNotAcceptable{}
var _ NotAcceptable = internalNotAcceptable{}
var ErrNotAcceptable error = NotAcceptableWrap(nil)
type NotAcceptable interface { type NotAcceptable interface {
ClientError ClientError
NotAcceptable() NotAcceptable()
@ -19,8 +25,8 @@ func (receiver internalNotAcceptable) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalNotAcceptable) Err() error { func (internalNotAcceptable) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalNotAcceptable) ClientError() { func (internalNotAcceptable) ClientError() {
@ -30,3 +36,7 @@ func (internalNotAcceptable) ClientError() {
func (internalNotAcceptable) NotAcceptable() { func (internalNotAcceptable) NotAcceptable() {
// Nothing here. // 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 package errhttp
var _ Error = internalNotExtended{}
var _ ServerError = internalNotExtended{}
var _ NotExtended = internalNotExtended{}
var ErrNotExtended error = NotExtendedWrap(nil)
type NotExtended interface { type NotExtended interface {
ServerError ServerError
NotExtended() NotExtended()
} }
var _ NotExtended = internalNotExtended{}
type internalNotExtended struct { type internalNotExtended struct {
err error err error
} }
@ -19,8 +27,8 @@ func (receiver internalNotExtended) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalNotExtended) Err() error { func (internalNotExtended) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalNotExtended) ServerError() { func (internalNotExtended) ServerError() {
@ -30,3 +38,7 @@ func (internalNotExtended) ServerError() {
func (internalNotExtended) NotExtended() { func (internalNotExtended) NotExtended() {
// Nothing here. // Nothing here.
} }
func (receiver internalNotExtended) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
var _ Error = internalNotFound{}
var _ ClientError = internalNotFound{}
var _ NotFound = internalNotFound{}
var ErrNotFound error = NotFoundWrap(nil)
type NotFound interface { type NotFound interface {
ClientError ClientError
NotFound () NotFound ()
@ -19,8 +25,8 @@ func (receiver internalNotFound ) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalNotFound ) Err() error { func (internalNotFound ) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalNotFound ) ClientError() { func (internalNotFound ) ClientError() {
@ -30,3 +36,7 @@ func (internalNotFound ) ClientError() {
func (internalNotFound ) NotFound() { func (internalNotFound ) NotFound() {
// Nothing here. // 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 package errhttp
var _ Error = internalNotImplemented{}
var _ ServerError = internalNotImplemented{}
var _ NotImplemented = internalNotImplemented{}
var ErrNotImplemented error = NotImplementedWrap(nil)
type NotImplemented interface { type NotImplemented interface {
ServerError ServerError
NotImplemented() NotImplemented()
} }
var _ NotImplemented = internalNotImplemented{}
type internalNotImplemented struct { type internalNotImplemented struct {
err error err error
} }
@ -19,8 +27,8 @@ func (receiver internalNotImplemented) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalNotImplemented) Err() error { func (internalNotImplemented) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalNotImplemented) ServerError() { func (internalNotImplemented) ServerError() {
@ -30,3 +38,7 @@ func (internalNotImplemented) ServerError() {
func (internalNotImplemented) NotImplemented() { func (internalNotImplemented) NotImplemented() {
// Nothing here. // 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 package errhttp
var _ Error = internalPaymentRequired{}
var _ ClientError = internalPaymentRequired{}
var _ PaymentRequired = internalPaymentRequired{}
var ErrPaymentRequired error = PaymentRequiredWrap(nil)
type PaymentRequired interface { type PaymentRequired interface {
ClientError ClientError
PaymentRequired() PaymentRequired()
@ -19,10 +25,11 @@ func (receiver internalPaymentRequired) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalPaymentRequired) Err() error { func (internalPaymentRequired) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalPaymentRequired) ClientError() { func (internalPaymentRequired) ClientError() {
// Nothing here. // Nothing here.
} }
@ -30,3 +37,7 @@ func (internalPaymentRequired) ClientError() {
func (internalPaymentRequired) PaymentRequired() { func (internalPaymentRequired) PaymentRequired() {
// Nothing here. // 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 package errhttp
var _ Error = internalPreconditionFailed{}
var _ ClientError = internalPreconditionFailed{}
var _ PreconditionFailed = internalPreconditionFailed{}
var ErrPreconditionFailed error = PreconditionFailedWrap(nil)
type PreconditionFailed interface { type PreconditionFailed interface {
ClientError ClientError
PreconditionFailed() PreconditionFailed()
@ -19,8 +25,8 @@ func (receiver internalPreconditionFailed) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalPreconditionFailed) Err() error { func (internalPreconditionFailed) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalPreconditionFailed) ClientError() { func (internalPreconditionFailed) ClientError() {
@ -30,3 +36,7 @@ func (internalPreconditionFailed) ClientError() {
func (internalPreconditionFailed) PreconditionFailed() { func (internalPreconditionFailed) PreconditionFailed() {
// Nothing here. // 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 package errhttp
var _ Error = internalPreconditionRequired{}
var _ ClientError = internalPreconditionRequired{}
var _ PreconditionRequired = internalPreconditionRequired{}
var ErrPreconditionRequired error = PreconditionRequiredWrap(nil)
type PreconditionRequired interface { type PreconditionRequired interface {
ClientError ClientError
PreconditionRequired() PreconditionRequired()
@ -19,8 +25,8 @@ func (receiver internalPreconditionRequired) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalPreconditionRequired) Err() error { func (internalPreconditionRequired) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalPreconditionRequired) ClientError() { func (internalPreconditionRequired) ClientError() {
@ -31,3 +37,6 @@ func (internalPreconditionRequired) PreconditionRequired() {
// Nothing here. // 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 package errhttp
var _ Error = internalProxyAuthRequired{}
var _ ClientError = internalProxyAuthRequired{}
var _ ProxyAuthRequired = internalProxyAuthRequired{}
var ErrProxyAuthRequired error = ProxyAuthRequiredWrap(nil)
type ProxyAuthRequired interface { type ProxyAuthRequired interface {
ClientError ClientError
ProxyAuthRequired() ProxyAuthRequired()
@ -19,8 +25,8 @@ func (receiver internalProxyAuthRequired) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalProxyAuthRequired) Err() error { func (internalProxyAuthRequired) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalProxyAuthRequired) ClientError() { func (internalProxyAuthRequired) ClientError() {
@ -30,3 +36,7 @@ func (internalProxyAuthRequired) ClientError() {
func (internalProxyAuthRequired) ProxyAuthRequired() { func (internalProxyAuthRequired) ProxyAuthRequired() {
// Nothing here. // 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 package errhttp
var _ Error = internalRequestedRangeNotSatisfiable{}
var _ ClientError = internalRequestedRangeNotSatisfiable{}
var _ RequestedRangeNotSatisfiable = internalRequestedRangeNotSatisfiable{}
var ErrRequestedRangeNotSatisfiable error = RequestedRangeNotSatisfiableWrap(nil)
type RequestedRangeNotSatisfiable interface { type RequestedRangeNotSatisfiable interface {
ClientError ClientError
RequestedRangeNotSatisfiable() RequestedRangeNotSatisfiable()
@ -19,8 +25,8 @@ func (receiver internalRequestedRangeNotSatisfiable) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalRequestedRangeNotSatisfiable) Err() error { func (internalRequestedRangeNotSatisfiable) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalRequestedRangeNotSatisfiable) ClientError() { func (internalRequestedRangeNotSatisfiable) ClientError() {
@ -30,3 +36,7 @@ func (internalRequestedRangeNotSatisfiable) ClientError() {
func (internalRequestedRangeNotSatisfiable) RequestedRangeNotSatisfiable() { func (internalRequestedRangeNotSatisfiable) RequestedRangeNotSatisfiable() {
// Nothing here. // 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 package errhttp
var _ Error = internalRequestEntityTooLarge{}
var _ ClientError = internalRequestEntityTooLarge{}
var _ RequestEntityTooLarge = internalRequestEntityTooLarge{}
var ErrRequestEntityTooLarge error = RequestEntityTooLargeWrap(nil)
type RequestEntityTooLarge interface { type RequestEntityTooLarge interface {
ClientError ClientError
RequestEntityTooLarge() RequestEntityTooLarge()
@ -19,8 +25,8 @@ func (receiver internalRequestEntityTooLarge) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalRequestEntityTooLarge) Err() error { func (internalRequestEntityTooLarge) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalRequestEntityTooLarge) ClientError() { func (internalRequestEntityTooLarge) ClientError() {
@ -30,3 +36,7 @@ func (internalRequestEntityTooLarge) ClientError() {
func (internalRequestEntityTooLarge) RequestEntityTooLarge() { func (internalRequestEntityTooLarge) RequestEntityTooLarge() {
// Nothing here. // 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 package errhttp
var _ Error = internalRequestHeaderFieldsTooLarge{}
var _ ClientError = internalRequestHeaderFieldsTooLarge{}
var _ RequestHeaderFieldsTooLarge = internalRequestHeaderFieldsTooLarge{}
var ErrRequestHeaderFieldsTooLarge error = RequestHeaderFieldsTooLargeWrap(nil)
type RequestHeaderFieldsTooLarge interface { type RequestHeaderFieldsTooLarge interface {
error ClientError
Err() error
RequestHeaderFieldsTooLarge() RequestHeaderFieldsTooLarge()
} }
@ -20,8 +25,8 @@ func (receiver internalRequestHeaderFieldsTooLarge) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalRequestHeaderFieldsTooLarge) Err() error { func (internalRequestHeaderFieldsTooLarge) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalRequestHeaderFieldsTooLarge) ClientError() { func (internalRequestHeaderFieldsTooLarge) ClientError() {
@ -31,3 +36,7 @@ func (internalRequestHeaderFieldsTooLarge) ClientError() {
func (internalRequestHeaderFieldsTooLarge) RequestHeaderFieldsTooLarge() { func (internalRequestHeaderFieldsTooLarge) RequestHeaderFieldsTooLarge() {
// Nothing here. // 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 package errhttp
var _ Error = internalRequestTimeout{}
var _ ClientError = internalRequestTimeout{}
var _ RequestTimeout = internalRequestTimeout{}
var ErrRequestTimeout error = RequestTimeoutWrap(nil)
type RequestTimeout interface { type RequestTimeout interface {
error ClientError
Err() error
RequestTimeout() RequestTimeout()
} }
@ -20,8 +25,8 @@ func (receiver internalRequestTimeout) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalRequestTimeout) Err() error { func (internalRequestTimeout) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalRequestTimeout) ClientError() { func (internalRequestTimeout) ClientError() {
@ -31,3 +36,7 @@ func (internalRequestTimeout) ClientError() {
func (internalRequestTimeout) RequestTimeout() { func (internalRequestTimeout) RequestTimeout() {
// Nothing here. // 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 package errhttp
var _ Error = internalRequestURITooLong{}
var _ ClientError = internalRequestURITooLong{}
var _ RequestURITooLong = internalRequestURITooLong{}
var ErrRequestURITooLong error = RequestURITooLongWrap(nil)
type RequestURITooLong interface { type RequestURITooLong interface {
error ClientError
Err() error
RequestURITooLong() RequestURITooLong()
} }
@ -20,8 +25,8 @@ func (receiver internalRequestURITooLong) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalRequestURITooLong) Err() error { func (internalRequestURITooLong) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalRequestURITooLong) ClientError() { func (internalRequestURITooLong) ClientError() {
@ -31,3 +36,7 @@ func (internalRequestURITooLong) ClientError() {
func (internalRequestURITooLong) RequestURITooLong() { func (internalRequestURITooLong) RequestURITooLong() {
// Nothing here. // 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 package errhttp
var _ Error = internalServiceUnavailable{}
var _ ServerError = internalServiceUnavailable{}
var _ ServiceUnavailable = internalServiceUnavailable{}
var ErrServiceUnavailable error = ServiceUnavailableWrap(nil)
type ServiceUnavailable interface { type ServiceUnavailable interface {
ServerError ServerError
ServiceUnavailable() ServiceUnavailable()
@ -19,8 +25,8 @@ func (receiver internalServiceUnavailable) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalServiceUnavailable) Err() error { func (internalServiceUnavailable) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalServiceUnavailable) ServerError() { func (internalServiceUnavailable) ServerError() {
@ -30,3 +36,7 @@ func (internalServiceUnavailable) ServerError() {
func (internalServiceUnavailable) ServiceUnavailable() { func (internalServiceUnavailable) ServiceUnavailable() {
// Nothing here. // Nothing here.
} }
func (receiver internalServiceUnavailable) Unwrap() error {
return receiver.err
}

View File

@ -1,5 +1,11 @@
package errhttp package errhttp
var _ Error = internalTeapot{}
var _ ClientError = internalTeapot{}
var _ Teapot = internalTeapot{}
var ErrTeapot error = TeapotWrap(nil)
type Teapot interface { type Teapot interface {
ClientError ClientError
Teapot() Teapot()
@ -19,8 +25,8 @@ func (receiver internalTeapot) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalTeapot) Err() error { func (internalTeapot) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalTeapot) ClientError() { func (internalTeapot) ClientError() {
@ -30,3 +36,7 @@ func (internalTeapot) ClientError() {
func (internalTeapot) Teapot() { func (internalTeapot) Teapot() {
// Nothing here. // 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 package errhttp
var _ Error = internalTooManyRequests{}
var _ ClientError = internalTooManyRequests{}
var _ TooManyRequests = internalTooManyRequests{}
var ErrTooManyRequests error = TooManyRequestsWrap(nil)
type TooManyRequests interface { type TooManyRequests interface {
ClientError ClientError
TooManyRequests() TooManyRequests()
@ -19,8 +25,8 @@ func (receiver internalTooManyRequests) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalTooManyRequests) Err() error { func (internalTooManyRequests) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalTooManyRequests) ClientError() { func (internalTooManyRequests) ClientError() {
@ -30,3 +36,7 @@ func (internalTooManyRequests) ClientError() {
func (internalTooManyRequests) TooManyRequests() { func (internalTooManyRequests) TooManyRequests() {
// Nothing here. // 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 package errhttp
var _ Error = internalUnauthorized{}
var _ ClientError = internalUnauthorized{}
var _ Unauthorized = internalUnauthorized{}
var ErrUnauthorized error = UnauthorizedWrap(nil)
type Unauthorized interface { type Unauthorized interface {
ClientError ClientError
Unauthorized() Unauthorized()
@ -19,8 +25,8 @@ func (receiver internalUnauthorized) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalUnauthorized) Err() error { func (internalUnauthorized) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalUnauthorized) ClientError() { func (internalUnauthorized) ClientError() {
@ -30,3 +36,7 @@ func (internalUnauthorized) ClientError() {
func (internalUnauthorized) Unauthorized() { func (internalUnauthorized) Unauthorized() {
// Nothing here. // 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 package errhttp
var _ Error = internalUnavailableForLegalReasons{}
var _ ClientError = internalUnavailableForLegalReasons{}
var _ UnavailableForLegalReasons = internalUnavailableForLegalReasons{}
var ErrUnavailableForLegalReasons error = UnavailableForLegalReasonsWrap(nil)
type UnavailableForLegalReasons interface { type UnavailableForLegalReasons interface {
ClientError ClientError
UnavailableForLegalReasons() UnavailableForLegalReasons()
@ -19,8 +25,8 @@ func (receiver internalUnavailableForLegalReasons) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalUnavailableForLegalReasons) Err() error { func (internalUnavailableForLegalReasons) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalUnavailableForLegalReasons) ClientError() { func (internalUnavailableForLegalReasons) ClientError() {
@ -31,3 +37,6 @@ func (internalUnavailableForLegalReasons) UnavailableForLegalReasons() {
// Nothing here. // 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 package errhttp
var _ Error = internalUnprocessableEntity{}
var _ ClientError = internalUnprocessableEntity{}
var _ UnprocessableEntity = internalUnprocessableEntity{}
var ErrUnprocessableEntity error = UnprocessableEntityWrap(nil)
type UnprocessableEntity interface { type UnprocessableEntity interface {
ClientError ClientError
UnprocessableEntity() UnprocessableEntity()
@ -19,8 +25,8 @@ func (receiver internalUnprocessableEntity) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalUnprocessableEntity) Err() error { func (internalUnprocessableEntity) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalUnprocessableEntity) ClientError() { func (internalUnprocessableEntity) ClientError() {
@ -30,3 +36,7 @@ func (internalUnprocessableEntity) ClientError() {
func (internalUnprocessableEntity) UnprocessableEntity() { func (internalUnprocessableEntity) UnprocessableEntity() {
// Nothing here. // 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 package errhttp
var _ Error = internalUnsupportedMediaType{}
var _ ClientError = internalUnsupportedMediaType{}
var _ UnsupportedMediaType = internalUnsupportedMediaType{}
var ErrUnsupportedMediaType error = UnsupportedMediaTypeWrap(nil)
type UnsupportedMediaType interface { type UnsupportedMediaType interface {
ClientError ClientError
UnsupportedMediaType() UnsupportedMediaType()
@ -19,8 +25,8 @@ func (receiver internalUnsupportedMediaType) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalUnsupportedMediaType) Err() error { func (internalUnsupportedMediaType) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalUnsupportedMediaType) ClientError() { func (internalUnsupportedMediaType) ClientError() {
@ -30,3 +36,7 @@ func (internalUnsupportedMediaType) ClientError() {
func (internalUnsupportedMediaType) UnsupportedMediaType() { func (internalUnsupportedMediaType) UnsupportedMediaType() {
// Nothing here. // 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 package errhttp
var _ Error = internalUpgradeRequired{}
var _ ClientError = internalUpgradeRequired{}
var _ UpgradeRequired = internalUpgradeRequired{}
var ErrUpgradeRequired error = UpgradeRequiredWrap(nil)
type UpgradeRequired interface { type UpgradeRequired interface {
ClientError ClientError
UpgradeRequired() UpgradeRequired()
@ -19,8 +25,8 @@ func (receiver internalUpgradeRequired) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalUpgradeRequired) Err() error { func (internalUpgradeRequired) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalUpgradeRequired) ClientError() { func (internalUpgradeRequired) ClientError() {
@ -30,3 +36,7 @@ func (internalUpgradeRequired) ClientError() {
func (internalUpgradeRequired) UpgradeRequired() { func (internalUpgradeRequired) UpgradeRequired() {
// Nothing here. // 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 package errhttp
var _ Error = internalVariantAlsoNegotiates{}
var _ ServerError = internalVariantAlsoNegotiates{}
var _ VariantAlsoNegotiates = internalVariantAlsoNegotiates{}
var ErrVariantAlsoNegotiates error = VariantAlsoNegotiatesWrap(nil)
type VariantAlsoNegotiates interface { type VariantAlsoNegotiates interface {
ServerError ServerError
VariantAlsoNegotiates() VariantAlsoNegotiates()
} }
var _ VariantAlsoNegotiates = internalVariantAlsoNegotiates{}
type internalVariantAlsoNegotiates struct { type internalVariantAlsoNegotiates struct {
err error err error
} }
@ -19,8 +27,8 @@ func (receiver internalVariantAlsoNegotiates) Error() string {
return receiver.err.Error() return receiver.err.Error()
} }
func (receiver internalVariantAlsoNegotiates) Err() error { func (internalVariantAlsoNegotiates) ErrHTTP() {
return receiver.err // Nothing here.
} }
func (internalVariantAlsoNegotiates) ServerError() { func (internalVariantAlsoNegotiates) ServerError() {
@ -30,3 +38,7 @@ func (internalVariantAlsoNegotiates) ServerError() {
func (internalVariantAlsoNegotiates) VariantAlsoNegotiates() { func (internalVariantAlsoNegotiates) VariantAlsoNegotiates() {
// Nothing here. // Nothing here.
} }
func (receiver internalVariantAlsoNegotiates) Unwrap() error {
return receiver.err
}