Documentation ¶
Overview ¶
Package errors provides a way to return detailed information for an request error. The error is normally JSON encoded.
Index ¶
- Constants
- Variables
- func BadRequest(id, format string, a ...interface{}) error
- func Conflict(id, format string, a ...interface{}) error
- func Equal(err1 error, err2 error) bool
- func Forbidden(id, format string, a ...interface{}) error
- func InternalServerError(id, format string, a ...interface{}) error
- func MethodNotAllowed(id, format string, a ...interface{}) error
- func New(id, detail string, code int32) error
- func NotFound(id, format string, a ...interface{}) error
- func RequestEntityTooLarge(id, format string, a ...interface{}) error
- func Timeout(id, format string, a ...interface{}) error
- func TooManyRequests(id, format string, a ...interface{}) error
- func Unauthorized(id, format string, a ...interface{}) error
- type Error
- type MultiError
Constants ¶
View Source
const ( DefaultBadRequestID = "bad_request" DefaultForbiddenID = "forbidden" DefaultNotFoundID = "not_found" DefaultMethodNotAllowedID = "method_not_allowed" DefaultTooManyRequestsID = "too_many_requests" DefaultRequestEntityTooLargeID = "request_entity_too_large" DefaultInternalServerErrorID = "internal_server_error" DefaultConflictID = "conflict" DefaultRequestTimeoutID = "request_timeout" )
Variables ¶
View Source
var ( WithStack = errors.WithStack Wrap = errors.Wrap Wrapf = errors.Wrapf Is = errors.Is Errorf = errors.Errorf )
Define alias
Functions ¶
func BadRequest ¶
BadRequest generates a 400 error.
func InternalServerError ¶
InternalServerError generates a 500 error.
func MethodNotAllowed ¶
MethodNotAllowed generates a 405 error.
func RequestEntityTooLarge ¶
RequestEntityTooLarge generates a 413 error.
func TooManyRequests ¶
TooManyRequests generates a 429 error.
func Unauthorized ¶
Unauthorized generates a 401 error.
Types ¶
type Error ¶
type Error struct { ID string `json:"id,omitempty"` Code int32 `json:"code,omitempty"` Detail string `json:"detail,omitempty"` Status string `json:"status,omitempty"` }
Customize the error structure for implementation errors.Error interface
type MultiError ¶
type MultiError struct { Errors []error // contains filtered or unexported fields }
func NewMultiError ¶
func NewMultiError() *MultiError
func (*MultiError) Append ¶
func (e *MultiError) Append(err error)
func (*MultiError) AppendWithLock ¶
func (e *MultiError) AppendWithLock(err error)
func (*MultiError) Error ¶
func (e *MultiError) Error() string
func (*MultiError) HasErrors ¶
func (e *MultiError) HasErrors() bool
Click to show internal directories.
Click to hide internal directories.