Documentation
¶
Index ¶
- Variables
- func BadRequest(m string, fields ...string) error
- func Because(err error) error
- func Conflict(m string, fields ...string) error
- func ErrorJSON(w http.ResponseWriter, err error)
- func ErrorPlain(w http.ResponseWriter, err error)
- func FailedDependency(m string, fields ...string) error
- func Forbidden(m string, fields ...string) error
- func IsBadRequest(err error) bool
- func IsConflict(err error) bool
- func IsFailedDependency(err error) bool
- func IsForbidden(err error) bool
- func IsLocked(err error) bool
- func IsNotFound(err error) bool
- func IsPreconditionFailed(err error) bool
- func IsPreconditionRequired(err error) bool
- func IsUnauthorized(err error) bool
- func IsUnknown(err error) bool
- func IsUnprocessableEntity(err error) bool
- func Locked(m string, fields ...string) error
- func NotFound(m string, fields ...string) error
- func PreconditionFailed(m string, fields ...string) error
- func PreconditionRequired(m string, fields ...string) error
- func Say(err error) (int, string)
- func Unauthorized(m string, fields ...string) error
- func Unexpected() error
- func UnprocessableEntity(m string, fields ...string) error
- type Fail
- func (f *Fail) BadRequest(m string, details ...string) error
- func (f *Fail) Caller(skip int)
- func (f *Fail) Conflict(m string, details ...string) error
- func (f *Fail) Error() string
- func (f *Fail) FailedDependency(m string, details ...string) error
- func (f *Fail) Forbidden(m string, details ...string) error
- func (f *Fail) Format(s fmt.State, c rune)
- func (f *Fail) Locked(m string, details ...string) error
- func (f *Fail) NotFound(m string, details ...string) error
- func (f *Fail) PreconditionFailed(m string, details ...string) error
- func (f *Fail) PreconditionRequired(m string, details ...string) error
- func (f *Fail) String() string
- func (f *Fail) Unauthorized(m string, details ...string) error
- func (f *Fail) Unexpected() error
- func (f *Fail) UnprocessableEntity(m string, details ...string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnspecified is an error with no cause or reason. ErrUnspecified = fmt.Errorf("unspecified error") )
Functions ¶
func BadRequest ¶
BadRequest is a convenience function to return a BadRequest fail.
func ErrorJSON ¶
func ErrorJSON(w http.ResponseWriter, err error)
ErrorJSON complements `http.Error` by sending a fail response.
func ErrorPlain ¶
func ErrorPlain(w http.ResponseWriter, err error)
ErrorPlain complements `http.Error` by sending a fail response.
func FailedDependency ¶
FailedDependency is a convenience function to return a FailedDependency fail.
func IsBadRequest ¶
IsBadRequest returns true if fail is a BadRequest fail, false otherwise.
func IsConflict ¶
IsConflict returns true if fail is a Conflict fail, false otherwise.
func IsFailedDependency ¶
IsFailedDependency returns true if fail is a FailedDependency fail, false otherwise.
func IsForbidden ¶
IsForbidden returns true if fail is a Forbidden fail, false otherwise.
func IsNotFound ¶
IsNotFound returns true if fail is a NotFound fail, false otherwise.
func IsPreconditionFailed ¶
IsPreconditionFailed returns true if fail is a PreconditionFailed fail, false otherwise.
func IsPreconditionRequired ¶
IsPreconditionRequired returns true if fail is a PreconditionRequired fail, false otherwise.
func IsUnauthorized ¶
IsUnauthorized returns true if fail is a Unauthorized fail, false otherwise.
func IsUnprocessableEntity ¶
IsUnprocessableEntity returns true if fail is a UnprocessableEntity fail, false otherwise.
func PreconditionFailed ¶
PreconditionFailed is a convenience function to return a PreconditionFailed fail.
func PreconditionRequired ¶
PreconditionRequired is a convenience function to return a PreconditionRequired fail.
func Unauthorized ¶
Unauthorized is a convenience function to return an Unauthorized fail.
func Unexpected ¶
func Unexpected() error
Unexpected is a convenience function to return an Unexpected fail.
func UnprocessableEntity ¶
UnprocessableEntity is a convenience function to return a UnprocessableEntity fail.
Types ¶
type Fail ¶
type Fail struct {
Status int `json:"status"`
Message string `json:"message"`
Details []string `json:"details,omitempty"`
// contains filtered or unexported fields
}
Fail is an error that can be used in an HTTP response.
func (*Fail) BadRequest ¶
BadRequest changes the error to a "Bad Request" fail.
func (*Fail) FailedDependency ¶
FailedDependency changes the error to a "Failed Dependency" fail.
func (*Fail) PreconditionFailed ¶
PreconditionFailed changes the error to a "Precondition Failed" fail.
func (*Fail) PreconditionRequired ¶
PreconditionRequired changes the error to a "Precondition Required" fail.
func (*Fail) Unauthorized ¶
Unauthorized changes the error to an "Unauthorized" fail.
func (*Fail) Unexpected ¶
Unexpected morphs the error into an "Internal Server Error" fail.