From c38ee02a49d6522c2374244426c5b827632ea410 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Mon, 6 Feb 2017 12:58:13 -0800 Subject: [PATCH] client errors --- badrequest.go | 32 +++++++++++++++++++++ badrequest_test.go | 14 ++++++++++ clienterror.go | 6 ++++ clienterror_test.go | 42 ++++++++++++++++++++++++++++ conflict.go | 32 +++++++++++++++++++++ conflict_test.go | 14 ++++++++++ error.go | 6 ++++ expectationfailed.go | 32 +++++++++++++++++++++ expectationfailed_test.go | 14 ++++++++++ faileddependency.go | 33 ++++++++++++++++++++++ faileddependency_test.go | 14 ++++++++++ forbidden.go | 33 ++++++++++++++++++++++ forbidden_test.go | 14 ++++++++++ gone.go | 33 ++++++++++++++++++++++ gone_test.go | 14 ++++++++++ lengthrequired.go | 33 ++++++++++++++++++++++ lengthrequired_test.go | 14 ++++++++++ locked.go | 32 +++++++++++++++++++++ locked_test.go | 14 ++++++++++ methodnotallowed.go | 33 ++++++++++++++++++++++ methodnotallowed_test.go | 14 ++++++++++ notacceptable.go | 32 +++++++++++++++++++++ notacceptable_test.go | 14 ++++++++++ notfound.go | 32 +++++++++++++++++++++ notfound_test.go | 14 ++++++++++ paymentrequired.go | 32 +++++++++++++++++++++ paymentrequired_test.go | 14 ++++++++++ preconditionfailed.go | 32 +++++++++++++++++++++ preconditionfailed_test.go | 14 ++++++++++ preconditionrequired.go | 33 ++++++++++++++++++++++ preconditionrequired_test.go | 14 ++++++++++ proxyauthrequired.go | 32 +++++++++++++++++++++ proxyauthrequired_test.go | 14 ++++++++++ requestedrangenotsatisfiable.go | 32 +++++++++++++++++++++ requestedrangenotsatisfiable_test.go | 14 ++++++++++ requestentitytoolarge.go | 32 +++++++++++++++++++++ requestentitytoolarge_test.go | 14 ++++++++++ requestheaderfieldstoolarge.go | 33 ++++++++++++++++++++++ requestheaderfieldstoolarge_test.go | 14 ++++++++++ requesttimeout.go | 33 ++++++++++++++++++++++ requesttimeout_test.go | 14 ++++++++++ requesturitoolong.go | 33 ++++++++++++++++++++++ requesturitoolong_test.go | 14 ++++++++++ servererror.go | 6 ++++ teapot.go | 32 +++++++++++++++++++++ teapot_test.go | 14 ++++++++++ toomanyrequests.go | 32 +++++++++++++++++++++ toomanyrequests_test.go | 14 ++++++++++ unauthorized.go | 32 +++++++++++++++++++++ unauthorized_test.go | 14 ++++++++++ unavailableforlegalreasons.go | 33 ++++++++++++++++++++++ unavailableforlegalreasons_test.go | 14 ++++++++++ unprocessableentity.go | 32 +++++++++++++++++++++ unprocessableentity_test.go | 14 ++++++++++ unsupportedmediatype.go | 32 +++++++++++++++++++++ unsupportedmediatype_test.go | 14 ++++++++++ upgraderequired.go | 32 +++++++++++++++++++++ upgraderequired_test.go | 14 ++++++++++ 58 files changed, 1312 insertions(+) create mode 100644 badrequest.go create mode 100644 badrequest_test.go create mode 100644 clienterror.go create mode 100644 clienterror_test.go create mode 100644 conflict.go create mode 100644 conflict_test.go create mode 100644 error.go create mode 100644 expectationfailed.go create mode 100644 expectationfailed_test.go create mode 100644 faileddependency.go create mode 100644 faileddependency_test.go create mode 100644 forbidden.go create mode 100644 forbidden_test.go create mode 100644 gone.go create mode 100644 gone_test.go create mode 100644 lengthrequired.go create mode 100644 lengthrequired_test.go create mode 100644 locked.go create mode 100644 locked_test.go create mode 100644 methodnotallowed.go create mode 100644 methodnotallowed_test.go create mode 100644 notacceptable.go create mode 100644 notacceptable_test.go create mode 100644 notfound.go create mode 100644 notfound_test.go create mode 100644 paymentrequired.go create mode 100644 paymentrequired_test.go create mode 100644 preconditionfailed.go create mode 100644 preconditionfailed_test.go create mode 100644 preconditionrequired.go create mode 100644 preconditionrequired_test.go create mode 100644 proxyauthrequired.go create mode 100644 proxyauthrequired_test.go create mode 100644 requestedrangenotsatisfiable.go create mode 100644 requestedrangenotsatisfiable_test.go create mode 100644 requestentitytoolarge.go create mode 100644 requestentitytoolarge_test.go create mode 100644 requestheaderfieldstoolarge.go create mode 100644 requestheaderfieldstoolarge_test.go create mode 100644 requesttimeout.go create mode 100644 requesttimeout_test.go create mode 100644 requesturitoolong.go create mode 100644 requesturitoolong_test.go create mode 100644 servererror.go create mode 100644 teapot.go create mode 100644 teapot_test.go create mode 100644 toomanyrequests.go create mode 100644 toomanyrequests_test.go create mode 100644 unauthorized.go create mode 100644 unauthorized_test.go create mode 100644 unavailableforlegalreasons.go create mode 100644 unavailableforlegalreasons_test.go create mode 100644 unprocessableentity.go create mode 100644 unprocessableentity_test.go create mode 100644 unsupportedmediatype.go create mode 100644 unsupportedmediatype_test.go create mode 100644 upgraderequired.go create mode 100644 upgraderequired_test.go diff --git a/badrequest.go b/badrequest.go new file mode 100644 index 0000000..2ce1816 --- /dev/null +++ b/badrequest.go @@ -0,0 +1,32 @@ +package errhttp + +type BadRequest interface { + ClientError + BadRequest() +} + +type internalBadRequest struct { + err error +} + +func BadRequestWrap(err error) error { + return internalBadRequest{ + err:err, + } +} + +func (receiver internalBadRequest) Error() string { + return receiver.err.Error() +} + +func (receiver internalBadRequest) Err() error { + return receiver.err +} + +func (internalBadRequest) ClientError() { + // Nothing here. +} + +func (internalBadRequest) BadRequest() { + // Nothing here. +} diff --git a/badrequest_test.go b/badrequest_test.go new file mode 100644 index 0000000..ba9a93f --- /dev/null +++ b/badrequest_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/clienterror.go b/clienterror.go new file mode 100644 index 0000000..27f8324 --- /dev/null +++ b/clienterror.go @@ -0,0 +1,6 @@ +package errhttp + +type ClientError interface { + Error + ClientError() +} diff --git a/clienterror_test.go b/clienterror_test.go new file mode 100644 index 0000000..ffd0d4e --- /dev/null +++ b/clienterror_test.go @@ -0,0 +1,42 @@ +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.") + } +} diff --git a/conflict.go b/conflict.go new file mode 100644 index 0000000..a2945c6 --- /dev/null +++ b/conflict.go @@ -0,0 +1,32 @@ +package errhttp + +type Conflict interface { + ClientError + Conflict() +} + +type internalConflict struct { + err error +} + +func ConflictWrap(err error) error { + return internalConflict{ + err:err, + } +} + +func (receiver internalConflict) Error() string { + return receiver.err.Error() +} + +func (receiver internalConflict) Err() error { + return receiver.err +} + +func (internalConflict) ClientError() { + // Nothing here. +} + +func (internalConflict) Conflict() { + // Nothing here. +} diff --git a/conflict_test.go b/conflict_test.go new file mode 100644 index 0000000..c5132a6 --- /dev/null +++ b/conflict_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/error.go b/error.go new file mode 100644 index 0000000..1848abb --- /dev/null +++ b/error.go @@ -0,0 +1,6 @@ +package errhttp + +type Error interface { + error + Err() error +} diff --git a/expectationfailed.go b/expectationfailed.go new file mode 100644 index 0000000..6a77270 --- /dev/null +++ b/expectationfailed.go @@ -0,0 +1,32 @@ +package errhttp + +type ExpectationFailed interface { + ClientError + ExpectationFailed() +} + +type internalExpectationFailed struct { + err error +} + +func ExpectationFailedWrap(err error) error { + return internalExpectationFailed{ + err:err, + } +} + +func (receiver internalExpectationFailed) Error() string { + return receiver.err.Error() +} + +func (receiver internalExpectationFailed) Err() error { + return receiver.err +} + +func (internalExpectationFailed) ClientError() { + // Nothing here. +} + +func (internalExpectationFailed) ExpectationFailed() { + // Nothing here. +} diff --git a/expectationfailed_test.go b/expectationfailed_test.go new file mode 100644 index 0000000..c5dc7d7 --- /dev/null +++ b/expectationfailed_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/faileddependency.go b/faileddependency.go new file mode 100644 index 0000000..5992003 --- /dev/null +++ b/faileddependency.go @@ -0,0 +1,33 @@ +package errhttp + +type FailedDependency interface { + ClientError + FailedDependency() +} + +type internalFailedDependency struct { + err error +} + +func FailedDependencyWrap(err error) error { + return internalFailedDependency{ + err:err, + } +} + +func (receiver internalFailedDependency) Error() string { + return receiver.err.Error() +} + +func (receiver internalFailedDependency) Err() error { + return receiver.err +} + +func (internalFailedDependency) ClientError() { + // Nothing here. +} + +func (internalFailedDependency) FailedDependency() { + // Nothing here. +} + diff --git a/faileddependency_test.go b/faileddependency_test.go new file mode 100644 index 0000000..959a2ac --- /dev/null +++ b/faileddependency_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/forbidden.go b/forbidden.go new file mode 100644 index 0000000..783204a --- /dev/null +++ b/forbidden.go @@ -0,0 +1,33 @@ +package errhttp + +type Forbidden interface { + ClientError + Forbidden() +} + +type internalForbidden struct { + err error +} + +func ForbiddenWrap(err error) error { + return internalForbidden{ + err:err, + } +} + +func (receiver internalForbidden) Error() string { + return receiver.err.Error() +} + +func (receiver internalForbidden) Err() error { + return receiver.err +} + +func (internalForbidden) ClientError() { + // Nothing here. +} + +func (internalForbidden) Forbidden() { + // Nothing here. +} + diff --git a/forbidden_test.go b/forbidden_test.go new file mode 100644 index 0000000..543c675 --- /dev/null +++ b/forbidden_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/gone.go b/gone.go new file mode 100644 index 0000000..19e88fc --- /dev/null +++ b/gone.go @@ -0,0 +1,33 @@ +package errhttp + +type Gone interface { + ClientError() + Gone() +} + +type internalGone struct { + err error +} + +func GoneWrap(err error) error { + return internalGone{ + err:err, + } +} + +func (receiver internalGone) Error() string { + return receiver.err.Error() +} + +func (receiver internalGone) Err() error { + return receiver.err +} + +func (internalGone) ClientError() { + // Nothing here. +} + +func (internalGone) Gone() { + // Nothing here. +} + diff --git a/gone_test.go b/gone_test.go new file mode 100644 index 0000000..d155e40 --- /dev/null +++ b/gone_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/lengthrequired.go b/lengthrequired.go new file mode 100644 index 0000000..6dae353 --- /dev/null +++ b/lengthrequired.go @@ -0,0 +1,33 @@ +package errhttp + +type LengthRequired interface { + ClientError + LengthRequired() +} + +type internalLengthRequired struct { + err error +} + +func LengthRequiredWrap(err error) error { + return internalLengthRequired{ + err:err, + } +} + +func (receiver internalLengthRequired) Error() string { + return receiver.err.Error() +} + +func (receiver internalLengthRequired) Err() error { + return receiver.err +} + +func (internalLengthRequired) ClientError() { + // Nothing here. +} + +func (internalLengthRequired) LengthRequired() { + // Nothing here. +} + diff --git a/lengthrequired_test.go b/lengthrequired_test.go new file mode 100644 index 0000000..7b086fe --- /dev/null +++ b/lengthrequired_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/locked.go b/locked.go new file mode 100644 index 0000000..8b7750c --- /dev/null +++ b/locked.go @@ -0,0 +1,32 @@ +package errhttp + +type Locked interface { + ClientError + Locked() +} + +type internalLocked struct { + err error +} + +func LockedWrap(err error) error { + return internalLocked{ + err:err, + } +} + +func (receiver internalLocked) Error() string { + return receiver.err.Error() +} + +func (receiver internalLocked) Err() error { + return receiver.err +} + +func (internalLocked) ClientError() { + // Nothing here. +} + +func (internalLocked) Locked() { + // Nothing here. +} diff --git a/locked_test.go b/locked_test.go new file mode 100644 index 0000000..588ebe9 --- /dev/null +++ b/locked_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/methodnotallowed.go b/methodnotallowed.go new file mode 100644 index 0000000..01fce93 --- /dev/null +++ b/methodnotallowed.go @@ -0,0 +1,33 @@ +package errhttp + +type MethodNotAllowed interface { + ClientError + MethodNotAllowed() +} + +type internalMethodNotAllowed struct { + err error +} + +func MethodNotAllowedWrap(err error) error { + return internalMethodNotAllowed{ + err:err, + } +} + +func (receiver internalMethodNotAllowed) Error() string { + return receiver.err.Error() +} + +func (receiver internalMethodNotAllowed) Err() error { + return receiver.err +} + +func (internalMethodNotAllowed) ClientError() { + // Nothing here. +} + +func (internalMethodNotAllowed) MethodNotAllowed() { + // Nothing here. +} + diff --git a/methodnotallowed_test.go b/methodnotallowed_test.go new file mode 100644 index 0000000..6927b25 --- /dev/null +++ b/methodnotallowed_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/notacceptable.go b/notacceptable.go new file mode 100644 index 0000000..84fcb67 --- /dev/null +++ b/notacceptable.go @@ -0,0 +1,32 @@ +package errhttp + +type NotAcceptable interface { + ClientError + NotAcceptable() +} + +type internalNotAcceptable struct { + err error +} + +func NotAcceptableWrap(err error) error { + return internalNotAcceptable{ + err:err, + } +} + +func (receiver internalNotAcceptable) Error() string { + return receiver.err.Error() +} + +func (receiver internalNotAcceptable) Err() error { + return receiver.err +} + +func (internalNotAcceptable) ClientError() { + // Nothing here. +} + +func (internalNotAcceptable) NotAcceptable() { + // Nothing here. +} diff --git a/notacceptable_test.go b/notacceptable_test.go new file mode 100644 index 0000000..4b45dfa --- /dev/null +++ b/notacceptable_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/notfound.go b/notfound.go new file mode 100644 index 0000000..4a1182d --- /dev/null +++ b/notfound.go @@ -0,0 +1,32 @@ +package errhttp + +type NotFound interface { + ClientError + NotFound () +} + +type internalNotFound struct { + err error +} + +func NotFoundWrap(err error) error { + return internalNotFound { + err:err, + } +} + +func (receiver internalNotFound ) Error() string { + return receiver.err.Error() +} + +func (receiver internalNotFound ) Err() error { + return receiver.err +} + +func (internalNotFound ) ClientError() { + // Nothing here. +} + +func (internalNotFound ) NotFound() { + // Nothing here. +} diff --git a/notfound_test.go b/notfound_test.go new file mode 100644 index 0000000..aaada0c --- /dev/null +++ b/notfound_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/paymentrequired.go b/paymentrequired.go new file mode 100644 index 0000000..e0f9788 --- /dev/null +++ b/paymentrequired.go @@ -0,0 +1,32 @@ +package errhttp + +type PaymentRequired interface { + ClientError + PaymentRequired() +} + +type internalPaymentRequired struct { + err error +} + +func PaymentRequiredWrap(err error) error { + return internalPaymentRequired{ + err:err, + } +} + +func (receiver internalPaymentRequired) Error() string { + return receiver.err.Error() +} + +func (receiver internalPaymentRequired) Err() error { + return receiver.err +} + +func (internalPaymentRequired) ClientError() { + // Nothing here. +} + +func (internalPaymentRequired) PaymentRequired() { + // Nothing here. +} diff --git a/paymentrequired_test.go b/paymentrequired_test.go new file mode 100644 index 0000000..544ddaa --- /dev/null +++ b/paymentrequired_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/preconditionfailed.go b/preconditionfailed.go new file mode 100644 index 0000000..526919a --- /dev/null +++ b/preconditionfailed.go @@ -0,0 +1,32 @@ +package errhttp + +type PreconditionFailed interface { + ClientError + PreconditionFailed() +} + +type internalPreconditionFailed struct { + err error +} + +func PreconditionFailedWrap(err error) error { + return internalPreconditionFailed{ + err:err, + } +} + +func (receiver internalPreconditionFailed) Error() string { + return receiver.err.Error() +} + +func (receiver internalPreconditionFailed) Err() error { + return receiver.err +} + +func (internalPreconditionFailed) ClientError() { + // Nothing here. +} + +func (internalPreconditionFailed) PreconditionFailed() { + // Nothing here. +} diff --git a/preconditionfailed_test.go b/preconditionfailed_test.go new file mode 100644 index 0000000..623795f --- /dev/null +++ b/preconditionfailed_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/preconditionrequired.go b/preconditionrequired.go new file mode 100644 index 0000000..3d1a960 --- /dev/null +++ b/preconditionrequired.go @@ -0,0 +1,33 @@ +package errhttp + +type PreconditionRequired interface { + ClientError + PreconditionRequired() +} + +type internalPreconditionRequired struct { + err error +} + +func PreconditionRequiredWrap(err error) error { + return internalPreconditionRequired{ + err:err, + } +} + +func (receiver internalPreconditionRequired) Error() string { + return receiver.err.Error() +} + +func (receiver internalPreconditionRequired) Err() error { + return receiver.err +} + +func (internalPreconditionRequired) ClientError() { + // Nothing here. +} + +func (internalPreconditionRequired) PreconditionRequired() { + // Nothing here. +} + diff --git a/preconditionrequired_test.go b/preconditionrequired_test.go new file mode 100644 index 0000000..b899a5a --- /dev/null +++ b/preconditionrequired_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/proxyauthrequired.go b/proxyauthrequired.go new file mode 100644 index 0000000..19fb288 --- /dev/null +++ b/proxyauthrequired.go @@ -0,0 +1,32 @@ +package errhttp + +type ProxyAuthRequired interface { + ClientError + ProxyAuthRequired() +} + +type internalProxyAuthRequired struct { + err error +} + +func ProxyAuthRequiredWrap(err error) error { + return internalProxyAuthRequired{ + err:err, + } +} + +func (receiver internalProxyAuthRequired) Error() string { + return receiver.err.Error() +} + +func (receiver internalProxyAuthRequired) Err() error { + return receiver.err +} + +func (internalProxyAuthRequired) ClientError() { + // Nothing here. +} + +func (internalProxyAuthRequired) ProxyAuthRequired() { + // Nothing here. +} diff --git a/proxyauthrequired_test.go b/proxyauthrequired_test.go new file mode 100644 index 0000000..9ccf013 --- /dev/null +++ b/proxyauthrequired_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/requestedrangenotsatisfiable.go b/requestedrangenotsatisfiable.go new file mode 100644 index 0000000..f0197ba --- /dev/null +++ b/requestedrangenotsatisfiable.go @@ -0,0 +1,32 @@ +package errhttp + +type RequestedRangeNotSatisfiable interface { + ClientError + RequestedRangeNotSatisfiable() +} + +type internalRequestedRangeNotSatisfiable struct { + err error +} + +func RequestedRangeNotSatisfiableWrap(err error) error { + return internalRequestedRangeNotSatisfiable{ + err:err, + } +} + +func (receiver internalRequestedRangeNotSatisfiable) Error() string { + return receiver.err.Error() +} + +func (receiver internalRequestedRangeNotSatisfiable) Err() error { + return receiver.err +} + +func (internalRequestedRangeNotSatisfiable) ClientError() { + // Nothing here. +} + +func (internalRequestedRangeNotSatisfiable) RequestedRangeNotSatisfiable() { + // Nothing here. +} diff --git a/requestedrangenotsatisfiable_test.go b/requestedrangenotsatisfiable_test.go new file mode 100644 index 0000000..05525b2 --- /dev/null +++ b/requestedrangenotsatisfiable_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/requestentitytoolarge.go b/requestentitytoolarge.go new file mode 100644 index 0000000..3086eda --- /dev/null +++ b/requestentitytoolarge.go @@ -0,0 +1,32 @@ +package errhttp + +type RequestEntityTooLarge interface { + ClientError + RequestEntityTooLarge() +} + +type internalRequestEntityTooLarge struct { + err error +} + +func RequestEntityTooLargeWrap(err error) error { + return internalRequestEntityTooLarge{ + err:err, + } +} + +func (receiver internalRequestEntityTooLarge) Error() string { + return receiver.err.Error() +} + +func (receiver internalRequestEntityTooLarge) Err() error { + return receiver.err +} + +func (internalRequestEntityTooLarge) ClientError() { + // Nothing here. +} + +func (internalRequestEntityTooLarge) RequestEntityTooLarge() { + // Nothing here. +} diff --git a/requestentitytoolarge_test.go b/requestentitytoolarge_test.go new file mode 100644 index 0000000..38b1013 --- /dev/null +++ b/requestentitytoolarge_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/requestheaderfieldstoolarge.go b/requestheaderfieldstoolarge.go new file mode 100644 index 0000000..3f64848 --- /dev/null +++ b/requestheaderfieldstoolarge.go @@ -0,0 +1,33 @@ +package errhttp + +type RequestHeaderFieldsTooLarge interface { + error + Err() error + RequestHeaderFieldsTooLarge() +} + +type internalRequestHeaderFieldsTooLarge struct { + err error +} + +func RequestHeaderFieldsTooLargeWrap(err error) error { + return internalRequestHeaderFieldsTooLarge{ + err:err, + } +} + +func (receiver internalRequestHeaderFieldsTooLarge) Error() string { + return receiver.err.Error() +} + +func (receiver internalRequestHeaderFieldsTooLarge) Err() error { + return receiver.err +} + +func (internalRequestHeaderFieldsTooLarge) ClientError() { + // Nothing here. +} + +func (internalRequestHeaderFieldsTooLarge) RequestHeaderFieldsTooLarge() { + // Nothing here. +} diff --git a/requestheaderfieldstoolarge_test.go b/requestheaderfieldstoolarge_test.go new file mode 100644 index 0000000..49e82af --- /dev/null +++ b/requestheaderfieldstoolarge_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/requesttimeout.go b/requesttimeout.go new file mode 100644 index 0000000..5b1be9f --- /dev/null +++ b/requesttimeout.go @@ -0,0 +1,33 @@ +package errhttp + +type RequestTimeout interface { + error + Err() error + RequestTimeout() +} + +type internalRequestTimeout struct { + err error +} + +func RequestTimeoutWrap(err error) error { + return internalRequestTimeout{ + err:err, + } +} + +func (receiver internalRequestTimeout) Error() string { + return receiver.err.Error() +} + +func (receiver internalRequestTimeout) Err() error { + return receiver.err +} + +func (internalRequestTimeout) ClientError() { + // Nothing here. +} + +func (internalRequestTimeout) RequestTimeout() { + // Nothing here. +} diff --git a/requesttimeout_test.go b/requesttimeout_test.go new file mode 100644 index 0000000..a9629a9 --- /dev/null +++ b/requesttimeout_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/requesturitoolong.go b/requesturitoolong.go new file mode 100644 index 0000000..53be12a --- /dev/null +++ b/requesturitoolong.go @@ -0,0 +1,33 @@ +package errhttp + +type RequestURITooLong interface { + error + Err() error + RequestURITooLong() +} + +type internalRequestURITooLong struct { + err error +} + +func RequestURITooLongWrap(err error) error { + return internalRequestURITooLong{ + err:err, + } +} + +func (receiver internalRequestURITooLong) Error() string { + return receiver.err.Error() +} + +func (receiver internalRequestURITooLong) Err() error { + return receiver.err +} + +func (internalRequestURITooLong) ClientError() { + // Nothing here. +} + +func (internalRequestURITooLong) RequestURITooLong() { + // Nothing here. +} diff --git a/requesturitoolong_test.go b/requesturitoolong_test.go new file mode 100644 index 0000000..b7ef868 --- /dev/null +++ b/requesturitoolong_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/servererror.go b/servererror.go new file mode 100644 index 0000000..dbd3255 --- /dev/null +++ b/servererror.go @@ -0,0 +1,6 @@ +package errhttp + +type ServerError interface { + Error + ServerError() +} diff --git a/teapot.go b/teapot.go new file mode 100644 index 0000000..b1fd56c --- /dev/null +++ b/teapot.go @@ -0,0 +1,32 @@ +package errhttp + +type Teapot interface { + ClientError + Teapot() +} + +type internalTeapot struct { + err error +} + +func TeapotWrap(err error) error { + return internalTeapot{ + err:err, + } +} + +func (receiver internalTeapot) Error() string { + return receiver.err.Error() +} + +func (receiver internalTeapot) Err() error { + return receiver.err +} + +func (internalTeapot) ClientError() { + // Nothing here. +} + +func (internalTeapot) Teapot() { + // Nothing here. +} diff --git a/teapot_test.go b/teapot_test.go new file mode 100644 index 0000000..bd5742e --- /dev/null +++ b/teapot_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/toomanyrequests.go b/toomanyrequests.go new file mode 100644 index 0000000..9b19ffa --- /dev/null +++ b/toomanyrequests.go @@ -0,0 +1,32 @@ +package errhttp + +type TooManyRequests interface { + ClientError + TooManyRequests() +} + +type internalTooManyRequests struct { + err error +} + +func TooManyRequestsWrap(err error) error { + return internalTooManyRequests{ + err:err, + } +} + +func (receiver internalTooManyRequests) Error() string { + return receiver.err.Error() +} + +func (receiver internalTooManyRequests) Err() error { + return receiver.err +} + +func (internalTooManyRequests) ClientError() { + // Nothing here. +} + +func (internalTooManyRequests) TooManyRequests() { + // Nothing here. +} diff --git a/toomanyrequests_test.go b/toomanyrequests_test.go new file mode 100644 index 0000000..05e2576 --- /dev/null +++ b/toomanyrequests_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/unauthorized.go b/unauthorized.go new file mode 100644 index 0000000..f0a60ea --- /dev/null +++ b/unauthorized.go @@ -0,0 +1,32 @@ +package errhttp + +type Unauthorized interface { + ClientError + Unauthorized() +} + +type internalUnauthorized struct { + err error +} + +func UnauthorizedWrap(err error) error { + return internalUnauthorized{ + err:err, + } +} + +func (receiver internalUnauthorized) Error() string { + return receiver.err.Error() +} + +func (receiver internalUnauthorized) Err() error { + return receiver.err +} + +func (internalUnauthorized) ClientError() { + // Nothing here. +} + +func (internalUnauthorized) Unauthorized() { + // Nothing here. +} diff --git a/unauthorized_test.go b/unauthorized_test.go new file mode 100644 index 0000000..e4d2430 --- /dev/null +++ b/unauthorized_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/unavailableforlegalreasons.go b/unavailableforlegalreasons.go new file mode 100644 index 0000000..ef24aab --- /dev/null +++ b/unavailableforlegalreasons.go @@ -0,0 +1,33 @@ +package errhttp + +type UnavailableForLegalReasons interface { + ClientError + UnavailableForLegalReasons() +} + +type internalUnavailableForLegalReasons struct { + err error +} + +func UnavailableForLegalReasonsWrap(err error) error { + return internalUnavailableForLegalReasons{ + err:err, + } +} + +func (receiver internalUnavailableForLegalReasons) Error() string { + return receiver.err.Error() +} + +func (receiver internalUnavailableForLegalReasons) Err() error { + return receiver.err +} + +func (internalUnavailableForLegalReasons) ClientError() { + // Nothing here. +} + +func (internalUnavailableForLegalReasons) UnavailableForLegalReasons() { + // Nothing here. +} + diff --git a/unavailableforlegalreasons_test.go b/unavailableforlegalreasons_test.go new file mode 100644 index 0000000..a9d156e --- /dev/null +++ b/unavailableforlegalreasons_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/unprocessableentity.go b/unprocessableentity.go new file mode 100644 index 0000000..1dde935 --- /dev/null +++ b/unprocessableentity.go @@ -0,0 +1,32 @@ +package errhttp + +type UnprocessableEntity interface { + ClientError + UnprocessableEntity() +} + +type internalUnprocessableEntity struct { + err error +} + +func UnprocessableEntityWrap(err error) error { + return internalUnprocessableEntity{ + err:err, + } +} + +func (receiver internalUnprocessableEntity) Error() string { + return receiver.err.Error() +} + +func (receiver internalUnprocessableEntity) Err() error { + return receiver.err +} + +func (internalUnprocessableEntity) ClientError() { + // Nothing here. +} + +func (internalUnprocessableEntity) UnprocessableEntity() { + // Nothing here. +} diff --git a/unprocessableentity_test.go b/unprocessableentity_test.go new file mode 100644 index 0000000..a1c9023 --- /dev/null +++ b/unprocessableentity_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/unsupportedmediatype.go b/unsupportedmediatype.go new file mode 100644 index 0000000..1030c53 --- /dev/null +++ b/unsupportedmediatype.go @@ -0,0 +1,32 @@ +package errhttp + +type UnsupportedMediaType interface { + ClientError + UnsupportedMediaType() +} + +type internalUnsupportedMediaType struct { + err error +} + +func UnsupportedMediaTypeWrap(err error) error { + return internalUnsupportedMediaType{ + err:err, + } +} + +func (receiver internalUnsupportedMediaType) Error() string { + return receiver.err.Error() +} + +func (receiver internalUnsupportedMediaType) Err() error { + return receiver.err +} + +func (internalUnsupportedMediaType) ClientError() { + // Nothing here. +} + +func (internalUnsupportedMediaType) UnsupportedMediaType() { + // Nothing here. +} diff --git a/unsupportedmediatype_test.go b/unsupportedmediatype_test.go new file mode 100644 index 0000000..ed870e2 --- /dev/null +++ b/unsupportedmediatype_test.go @@ -0,0 +1,14 @@ +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.") + } +} diff --git a/upgraderequired.go b/upgraderequired.go new file mode 100644 index 0000000..f4e3e5e --- /dev/null +++ b/upgraderequired.go @@ -0,0 +1,32 @@ +package errhttp + +type UpgradeRequired interface { + ClientError + UpgradeRequired() +} + +type internalUpgradeRequired struct { + err error +} + +func UpgradeRequiredWrap(err error) error { + return internalUpgradeRequired{ + err:err, + } +} + +func (receiver internalUpgradeRequired) Error() string { + return receiver.err.Error() +} + +func (receiver internalUpgradeRequired) Err() error { + return receiver.err +} + +func (internalUpgradeRequired) ClientError() { + // Nothing here. +} + +func (internalUpgradeRequired) UpgradeRequired() { + // Nothing here. +} diff --git a/upgraderequired_test.go b/upgraderequired_test.go new file mode 100644 index 0000000..6379794 --- /dev/null +++ b/upgraderequired_test.go @@ -0,0 +1,14 @@ +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.") + } +}