Charles Iliya Krempeaux 3bacef551e | ||
---|---|---|
LICENSE | ||
README.md | ||
badgateway.go | ||
badrequest.go | ||
clienterror.go | ||
conflict.go | ||
error.go | ||
expectationfailed.go | ||
faileddependency.go | ||
forbidden.go | ||
gatewaytimeout.go | ||
gone.go | ||
httpversionnotsupported.go | ||
insufficientstorage.go | ||
internalservererror.go | ||
lengthrequired.go | ||
locked.go | ||
loopdetected.go | ||
methodnotallowed.go | ||
networkauthenticationrequired.go | ||
notacceptable.go | ||
notextended.go | ||
notfound.go | ||
notimplemented.go | ||
payloadtoolarge.go | ||
paymentrequired.go | ||
preconditionfailed.go | ||
preconditionrequired.go | ||
proxyauthrequired.go | ||
requestedrangenotsatisfiable.go | ||
requestentitytoolarge.go | ||
requestheaderfieldstoolarge.go | ||
requesttimeout.go | ||
requesturitoolong.go | ||
servererror.go | ||
serviceunavailable.go | ||
teapot.go | ||
toomanyrequests.go | ||
unauthorized.go | ||
unavailableforlegalreasons.go | ||
unprocessableentity.go | ||
unsupportedmediatype.go | ||
upgraderequired.go | ||
uritoolong.go | ||
variantaisonegotiates.go |
README.md
go-errhttp
Package errhttp provides errors and types that make dealing with HTTP response errors easier, for the Go programming language.
Example
Here is an example of wrapping an error:
import "sourcecode.social/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
}
Here is an example of using one of the package global variable errors:
import "sourcecode.social/reiver/go-errhttp"
// ...
return errhttp.ErrBadRequest
// ...
switch err.(type) {
case errhttp.BadRequest:
//@TODO
case errhttp.NotFound:
//@TODO
case errhttp.InternalServerError:
//@TODO
case errhttp.ClientError:
//@TODO
case errhttp.ServerError:
//@TODO
default:
//@TODO
}
Documention
Online documentation, which includes examples, can be found at: http://godoc.org/sourcecode.social/reiver/go-errhttp