Documentation
¶
Index ¶
- type HTTPError
- func BadRequest() *HTTPError
- func Conflict() *HTTPError
- func Forbidden() *HTTPError
- func InternalServerError() *HTTPError
- func NotFound() *HTTPError
- func PaymentRequired() *HTTPError
- func PreconditionFailed() *HTTPError
- func RequestTimeout() *HTTPError
- func ServiceUnavailable() *HTTPError
- func ToHTTPError(err interface{}) *HTTPError
- func Unauthorized() *HTTPError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPError ¶
type HTTPError struct {
Status int `json:"-"`
Code string `json:"code"`
Reason string `json:"reason"`
}
HTTPError is a custom error type that implements the error interface.
func Conflict ¶
func Conflict() *HTTPError
Conflict is for requests that attempt paradoxical operations, such as re-creating the same resource.
func Forbidden ¶
func Forbidden() *HTTPError
Forbidden is for requests that do not have enough authority to execute the operation.
func InternalServerError ¶
func InternalServerError() *HTTPError
InternalServerError is for requests that cause an unexpected misbehaviour.
func NotFound ¶
func NotFound() *HTTPError
NotFound is for requests that try to access a non-existent resource.
func PaymentRequired ¶
func PaymentRequired() *HTTPError
PaymentRequired is for requests that require payment completion.
func PreconditionFailed ¶
func PreconditionFailed() *HTTPError
PreconditionFailed is for requests that do not satisfy pre-business layers of the application.
func RequestTimeout ¶
func RequestTimeout() *HTTPError
RequestTimeout is for requests that take longer than a certain time limit to execute.
func ServiceUnavailable ¶
func ServiceUnavailable() *HTTPError
ServiceUnavailable is returned when the system is not available enough to serve the request.
func ToHTTPError ¶
func ToHTTPError(err interface{}) *HTTPError
ToHTTPError converts any value to an appropriate HTTPError.
func Unauthorized ¶
func Unauthorized() *HTTPError
Unauthorized is for requests with invalid credentials.
func (*HTTPError) Error ¶
Error provides the reason behind the error, which is usually human-readable. If the reason is absent, it provides the error code instead.
func (*HTTPError) WithReasonErr ¶
WithReasonErr is a chainable method to set the reason of the HTTPError.
This accepts the reason as an error.
func (*HTTPError) WithReasonStr ¶
WithReasonStr is a chainable method to set the reason of the HTTPError.
This accepts the reason as a string.