Package errhttp provides errors and types that make dealing with HTTP response errors easier, for the Go programming language.
Go to file
Charles Iliya Krempeaux 2f430f79b6 updated README.md file 2023-08-14 05:57:44 -07:00
LICENSE initial commit 2017-02-06 12:57:57 -08:00
README.md updated README.md file 2023-08-14 05:57:44 -07:00
badgateway.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
badrequest.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
clienterror.go client errors 2017-02-06 12:58:13 -08:00
conflict.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
error.go removed Err() method. deal with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:03:00 -07:00
expectationfailed.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
faileddependency.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
forbidden.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
gatewaytimeout.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
gone.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
httpversionnotsupported.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
insufficientstorage.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
internalservererror.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
lengthrequired.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
locked.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
loopdetected.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
methodnotallowed.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
networkauthenticationrequired.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
notacceptable.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
notextended.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
notfound.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
notimplemented.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
payloadtoolarge.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
paymentrequired.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
preconditionfailed.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
preconditionrequired.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
proxyauthrequired.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
requestedrangenotsatisfiable.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
requestentitytoolarge.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
requestheaderfieldstoolarge.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
requesttimeout.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
requesturitoolong.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
servererror.go client errors 2017-02-06 12:58:13 -08:00
serviceunavailable.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
teapot.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
toomanyrequests.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
unauthorized.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
unavailableforlegalreasons.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
unprocessableentity.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
unsupportedmediatype.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
upgraderequired.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
uritoolong.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00
variantaisonegotiates.go dealt with internal type fitting interface in another way (other than a unit test) 2023-08-14 05:50:41 -07:00

README.md

go-errhttp

Package errhttp provides errors and types that make dealing with HTTP response errors easier, for the Go programming language.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/sourcecode.social/reiver/go-errhttp

GoDoc

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
	}