some fixes

master
Charles Iliya Krempeaux 2023-10-01 11:30:28 +09:00
parent ab4070bfdf
commit f09738021e
80 changed files with 2170 additions and 49 deletions

View File

@ -15,8 +15,6 @@ type BadGateway interface {
BadGateway()
}
var _ BadGateway = internalBadGateway{}
type internalBadGateway struct {
err error
}
@ -28,7 +26,11 @@ func BadGatewayWrap(err error) error {
}
func (receiver internalBadGateway) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalBadGateway) ErrHTTP() int {

View File

@ -8,7 +8,7 @@ var _ Error = internalBadRequest{}
var _ ClientError = internalBadRequest{}
var _ BadRequest = internalBadRequest{}
var ErrBadRequest = BadRequestWrap(nil)
var ErrBadRequest error = BadRequestWrap(nil)
type BadRequest interface {
ClientError
@ -26,7 +26,11 @@ func BadRequestWrap(err error) error {
}
func (receiver internalBadRequest) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalBadRequest) ErrHTTP() int {

View File

@ -8,7 +8,7 @@ var _ Error = internalConflict{}
var _ ClientError = internalConflict{}
var _ Conflict = internalConflict{}
var ErrConflict = ConflictWrap(nil)
var ErrConflict error = ConflictWrap(nil)
type Conflict interface {
ClientError
@ -26,7 +26,11 @@ func ConflictWrap(err error) error {
}
func (receiver internalConflict) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalConflict) ErrHTTP() int {

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrBadGateway(t *testing.T) {
var err error = errhttp.ErrBadGateway
casted := err.(errhttp.BadGateway)
var code int = http.StatusBadGateway
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrBadRequest(t *testing.T) {
var err error = errhttp.ErrBadRequest
casted := err.(errhttp.BadRequest)
var code int = http.StatusBadRequest
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrConflict(t *testing.T) {
var err error = errhttp.ErrConflict
casted := err.(errhttp.Conflict)
var code int = http.StatusConflict
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrExpectationFailed(t *testing.T) {
var err error = errhttp.ErrExpectationFailed
casted := err.(errhttp.ExpectationFailed)
var code int = http.StatusExpectationFailed
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrFailedDependency(t *testing.T) {
var err error = errhttp.ErrFailedDependency
casted := err.(errhttp.FailedDependency)
var code int = http.StatusFailedDependency
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrForbidden(t *testing.T) {
var err error = errhttp.ErrForbidden
casted := err.(errhttp.Forbidden)
var code int = http.StatusForbidden
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrGatewayTimeout(t *testing.T) {
var err error = errhttp.ErrGatewayTimeout
casted := err.(errhttp.GatewayTimeout)
var code int = http.StatusGatewayTimeout
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

52
errgone_test.go 100644
View File

@ -0,0 +1,52 @@
package errhttp_test
//@TODO: THIS TEST IS GIVING A WEIRD ERROR
/*
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrGone(t *testing.T) {
var err error = errhttp.ErrGone
casted := err.(errhttp.Gone)
var code int = http.StatusGone
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}
*/

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrHTTPVersionNotSupported(t *testing.T) {
var err error = errhttp.ErrHTTPVersionNotSupported
casted := err.(errhttp.HTTPVersionNotSupported)
var code int = http.StatusHTTPVersionNotSupported
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrInsufficientStorage(t *testing.T) {
var err error = errhttp.ErrInsufficientStorage
casted := err.(errhttp.InsufficientStorage)
var code int = http.StatusInsufficientStorage
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrInternalServerError(t *testing.T) {
var err error = errhttp.ErrInternalServerError
casted := err.(errhttp.InternalServerError)
var code int = http.StatusInternalServerError
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrLengthRequired(t *testing.T) {
var err error = errhttp.ErrLengthRequired
casted := err.(errhttp.LengthRequired)
var code int = http.StatusLengthRequired
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

49
errlocked_test.go 100644
View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrLocked(t *testing.T) {
var err error = errhttp.ErrLocked
casted := err.(errhttp.Locked)
var code int = http.StatusLocked
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrLoopDetected(t *testing.T) {
var err error = errhttp.ErrLoopDetected
casted := err.(errhttp.LoopDetected)
var code int = http.StatusLoopDetected
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrMethodNotAllowed(t *testing.T) {
var err error = errhttp.ErrMethodNotAllowed
casted := err.(errhttp.MethodNotAllowed)
var code int = http.StatusMethodNotAllowed
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrMisdirectedRequest(t *testing.T) {
var err error = errhttp.ErrMisdirectedRequest
casted := err.(errhttp.MisdirectedRequest)
var code int = http.StatusMisdirectedRequest
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrNetworkAuthenticationRequired(t *testing.T) {
var err error = errhttp.ErrNetworkAuthenticationRequired
casted := err.(errhttp.NetworkAuthenticationRequired)
var code int = http.StatusNetworkAuthenticationRequired
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrNotAcceptable(t *testing.T) {
var err error = errhttp.ErrNotAcceptable
casted := err.(errhttp.NotAcceptable)
var code int = http.StatusNotAcceptable
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrNotExtended(t *testing.T) {
var err error = errhttp.ErrNotExtended
casted := err.(errhttp.NotExtended)
var code int = http.StatusNotExtended
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrNotFound(t *testing.T) {
var err error = errhttp.ErrNotFound
casted := err.(errhttp.NotFound)
var code int = http.StatusNotFound
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrNotImplemented(t *testing.T) {
var err error = errhttp.ErrNotImplemented
casted := err.(errhttp.NotImplemented)
var code int = http.StatusNotImplemented
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrPaymentRequired(t *testing.T) {
var err error = errhttp.ErrPaymentRequired
casted := err.(errhttp.PaymentRequired)
var code int = http.StatusPaymentRequired
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrPreconditionFailed(t *testing.T) {
var err error = errhttp.ErrPreconditionFailed
casted := err.(errhttp.PreconditionFailed)
var code int = http.StatusPreconditionFailed
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrPreconditionRequired(t *testing.T) {
var err error = errhttp.ErrPreconditionRequired
casted := err.(errhttp.PreconditionRequired)
var code int = http.StatusPreconditionRequired
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrProxyAuthRequired(t *testing.T) {
var err error = errhttp.ErrProxyAuthRequired
casted := err.(errhttp.ProxyAuthRequired)
var code int = http.StatusProxyAuthRequired
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrRequestedRangeNotSatisfiable(t *testing.T) {
var err error = errhttp.ErrRequestedRangeNotSatisfiable
casted := err.(errhttp.RequestedRangeNotSatisfiable)
var code int = http.StatusRequestedRangeNotSatisfiable
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrRequestEntityTooLarge(t *testing.T) {
var err error = errhttp.ErrRequestEntityTooLarge
casted := err.(errhttp.RequestEntityTooLarge)
var code int = http.StatusRequestEntityTooLarge
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrRequestHeaderFieldsTooLarge(t *testing.T) {
var err error = errhttp.ErrRequestHeaderFieldsTooLarge
casted := err.(errhttp.RequestHeaderFieldsTooLarge)
var code int = http.StatusRequestHeaderFieldsTooLarge
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrRequestTimeout(t *testing.T) {
var err error = errhttp.ErrRequestTimeout
casted := err.(errhttp.RequestTimeout)
var code int = http.StatusRequestTimeout
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrRequestURITooLong(t *testing.T) {
var err error = errhttp.ErrRequestURITooLong
casted := err.(errhttp.RequestURITooLong)
var code int = http.StatusRequestURITooLong
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrServiceUnavailable(t *testing.T) {
var err error = errhttp.ErrServiceUnavailable
casted := err.(errhttp.ServiceUnavailable)
var code int = http.StatusServiceUnavailable
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

49
errteapot_test.go 100644
View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrTeapot(t *testing.T) {
var err error = errhttp.ErrTeapot
casted := err.(errhttp.Teapot)
var code int = http.StatusTeapot
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrTooEarly(t *testing.T) {
var err error = errhttp.ErrTooEarly
casted := err.(errhttp.TooEarly)
var code int = http.StatusTooEarly
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrTooManyRequests(t *testing.T) {
var err error = errhttp.ErrTooManyRequests
casted := err.(errhttp.TooManyRequests)
var code int = http.StatusTooManyRequests
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrUnauthorized(t *testing.T) {
var err error = errhttp.ErrUnauthorized
casted := err.(errhttp.Unauthorized)
var code int = http.StatusUnauthorized
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrUnavailableForLegalReasons(t *testing.T) {
var err error = errhttp.ErrUnavailableForLegalReasons
casted := err.(errhttp.UnavailableForLegalReasons)
var code int = http.StatusUnavailableForLegalReasons
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrUnprocessableEntity(t *testing.T) {
var err error = errhttp.ErrUnprocessableEntity
casted := err.(errhttp.UnprocessableEntity)
var code int = http.StatusUnprocessableEntity
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrUnsupportedMediaType(t *testing.T) {
var err error = errhttp.ErrUnsupportedMediaType
casted := err.(errhttp.UnsupportedMediaType)
var code int = http.StatusUnsupportedMediaType
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrUpgradeRequired(t *testing.T) {
var err error = errhttp.ErrUpgradeRequired
casted := err.(errhttp.UpgradeRequired)
var code int = http.StatusUpgradeRequired
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -0,0 +1,49 @@
package errhttp_test
import (
"testing"
"net/http"
"sourcecode.social/reiver/go-errhttp"
)
func TestErrVariantAlsoNegotiates(t *testing.T) {
var err error = errhttp.ErrVariantAlsoNegotiates
casted := err.(errhttp.VariantAlsoNegotiates)
var code int = http.StatusVariantAlsoNegotiates
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}

View File

@ -26,7 +26,11 @@ func ExpectationFailedWrap(err error) error {
}
func (receiver internalExpectationFailed) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalExpectationFailed) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func FailedDependencyWrap(err error) error {
}
func (receiver internalFailedDependency) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalFailedDependency) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func ForbiddenWrap(err error) error {
}
func (receiver internalForbidden) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalForbidden) ErrHTTP() int {

View File

@ -28,7 +28,11 @@ func GatewayTimeoutWrap(err error) error {
}
func (receiver internalGatewayTimeout) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalGatewayTimeout) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func GoneWrap(err error) error {
}
func (receiver internalGone) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalGone) ErrHTTP() int {

View File

@ -28,7 +28,11 @@ func HTTPVersionNotSupportedWrap(err error) error {
}
func (receiver internalHTTPVersionNotSupported) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalHTTPVersionNotSupported) ErrHTTP() int {

View File

@ -28,7 +28,11 @@ func InsufficientStorageWrap(err error) error {
}
func (receiver internalInsufficientStorage) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalInsufficientStorage) ErrHTTP() int {

View File

@ -28,7 +28,11 @@ func InternalServerErrorWrap(err error) error {
}
func (receiver internalInternalServerError) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalInternalServerError) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func LengthRequiredWrap(err error) error {
}
func (receiver internalLengthRequired) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalLengthRequired) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func LockedWrap(err error) error {
}
func (receiver internalLocked) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalLocked) ErrHTTP() int {

View File

@ -28,7 +28,11 @@ func LoopDetectedWrap(err error) error {
}
func (receiver internalLoopDetected) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalLoopDetected) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func MethodNotAllowedWrap(err error) error {
}
func (receiver internalMethodNotAllowed) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalMethodNotAllowed) ErrHTTP() int {

View File

@ -8,7 +8,7 @@ var _ Error = internalMisdirectedRequest{}
var _ ClientError = internalMisdirectedRequest{}
var _ MisdirectedRequest = internalMisdirectedRequest{}
var ErrMisdirectedRequest = MisdirectedRequestWrap(nil)
var ErrMisdirectedRequest error = MisdirectedRequestWrap(nil)
type MisdirectedRequest interface {
ClientError
@ -26,7 +26,11 @@ func MisdirectedRequestWrap(err error) error {
}
func (receiver internalMisdirectedRequest) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalMisdirectedRequest) ErrHTTP() int {

View File

@ -28,7 +28,11 @@ func NetworkAuthenticationRequiredWrap(err error) error {
}
func (receiver internalNetworkAuthenticationRequired) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalNetworkAuthenticationRequired) ErrHTTP() int {

View File

@ -26,6 +26,10 @@ func NotAcceptableWrap(err error) error {
}
func (receiver internalNotAcceptable) Error() string {
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return receiver.err.Error()
}

View File

@ -28,7 +28,11 @@ func NotExtendedWrap(err error) error {
}
func (receiver internalNotExtended) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalNotExtended) ErrHTTP() int {

View File

@ -25,19 +25,23 @@ func NotFoundWrap(err error) error {
}
}
func (receiver internalNotFound ) Error() string {
return receiver.err.Error()
func (receiver internalNotFound) Error() string {
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalNotFound ) ErrHTTP() int {
func (internalNotFound) ErrHTTP() int {
return http.StatusNotFound
}
func (internalNotFound ) ClientError() {
func (internalNotFound) ClientError() {
// Nothing here.
}
func (internalNotFound ) NotFound() {
func (internalNotFound) NotFound() {
// Nothing here.
}

View File

@ -28,7 +28,11 @@ func NotImplementedWrap(err error) error {
}
func (receiver internalNotImplemented) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalNotImplemented) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func PaymentRequiredWrap(err error) error {
}
func (receiver internalPaymentRequired) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalPaymentRequired) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func PreconditionFailedWrap(err error) error {
}
func (receiver internalPreconditionFailed) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalPreconditionFailed) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func PreconditionRequiredWrap(err error) error {
}
func (receiver internalPreconditionRequired) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalPreconditionRequired) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func ProxyAuthRequiredWrap(err error) error {
}
func (receiver internalProxyAuthRequired) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalProxyAuthRequired) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func RequestedRangeNotSatisfiableWrap(err error) error {
}
func (receiver internalRequestedRangeNotSatisfiable) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalRequestedRangeNotSatisfiable) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func RequestEntityTooLargeWrap(err error) error {
}
func (receiver internalRequestEntityTooLarge) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalRequestEntityTooLarge) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func RequestHeaderFieldsTooLargeWrap(err error) error {
}
func (receiver internalRequestHeaderFieldsTooLarge) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalRequestHeaderFieldsTooLarge) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func RequestTimeoutWrap(err error) error {
}
func (receiver internalRequestTimeout) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalRequestTimeout) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func RequestURITooLongWrap(err error) error {
}
func (receiver internalRequestURITooLong) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalRequestURITooLong) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func ServiceUnavailableWrap(err error) error {
}
func (receiver internalServiceUnavailable) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalServiceUnavailable) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func TeapotWrap(err error) error {
}
func (receiver internalTeapot) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalTeapot) ErrHTTP() int {

View File

@ -8,7 +8,7 @@ var _ Error = internalTooEarly{}
var _ ClientError = internalTooEarly{}
var _ TooEarly = internalTooEarly{}
var ErrTooEarly = TooEarlyWrap(nil)
var ErrTooEarly error = TooEarlyWrap(nil)
type TooEarly interface {
ClientError
@ -26,7 +26,11 @@ func TooEarlyWrap(err error) error {
}
func (receiver internalTooEarly) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalTooEarly) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func TooManyRequestsWrap(err error) error {
}
func (receiver internalTooManyRequests) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalTooManyRequests) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func UnauthorizedWrap(err error) error {
}
func (receiver internalUnauthorized) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalUnauthorized) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func UnavailableForLegalReasonsWrap(err error) error {
}
func (receiver internalUnavailableForLegalReasons) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalUnavailableForLegalReasons) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func UnprocessableEntityWrap(err error) error {
}
func (receiver internalUnprocessableEntity) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalUnprocessableEntity) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func UnsupportedMediaTypeWrap(err error) error {
}
func (receiver internalUnsupportedMediaType) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalUnsupportedMediaType) ErrHTTP() int {

View File

@ -26,7 +26,11 @@ func UpgradeRequiredWrap(err error) error {
}
func (receiver internalUpgradeRequired) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalUpgradeRequired) ErrHTTP() int {

View File

@ -28,7 +28,11 @@ func VariantAlsoNegotiatesWrap(err error) error {
}
func (receiver internalVariantAlsoNegotiates) Error() string {
return receiver.err.Error()
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalVariantAlsoNegotiates) ErrHTTP() int {