Documentation ¶
Index ¶
- func Debug(err error) string
- func Locate(err error) (runtime.Frame, bool)
- func NewBadRequestError(inner error) error
- func NewDatabaseQueryError(query string, inner error) error
- func NewInternalError(inner error) error
- func NewNotAllowedError(inner error) error
- func NewNotFoundError(entity string, identifier interface{}, inner error) error
- func NewUnauthorizedError(inner error) error
- func NewValidationError(entity, field string, inner error) error
- func Pin(err error) error
- type BadRequestError
- type DatabaseQueryError
- type InternalError
- type Locator
- type NotAllowedError
- type NotFoundError
- type Pinner
- type UnauthorizedError
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBadRequestError ¶ added in v0.4.1
NewBadRequestError builds an error for when a client send a bad request. e.g. a client sends a request that is missing a required field.
func NewDatabaseQueryError ¶
NewDatabaseQueryError builds an error for a failed database query. e.g. Trying to query the database, but the database rejects the query.
func NewInternalError ¶
NewInternalError builds a generic error. e.g. Trying to generate a random UUID, but the generation failed.
func NewNotAllowedError ¶
NewNotAllowedError builds an error for when a certain action is not allowed. e.g. Someone tries to delete something, but the record has been marked as permanenet.
func NewNotFoundError ¶
NewNotFoundError builds an error for an entity that cannot be found. e.g. Someone tries to retrieve a user, but the user for the given ID does not exist in the database.
func NewUnauthorizedError ¶
NewUnauthorizedError builds a new unauthorized error. e.g. Someone tried to access something they were not allowed to according to a permission policy.
func NewValidationError ¶
NewValidationError builds an error for failing to validate a field. e.g. Someone set the name field for a user to be empty, but the validation requires it to be present.
Types ¶
type BadRequestError ¶ added in v0.4.1
type BadRequestError struct {
// contains filtered or unexported fields
}
BadRequestError indicates that the server cannot or will not process the request due to something that is perceived to be a client error.
func (BadRequestError) Error ¶ added in v0.4.1
func (e BadRequestError) Error() string
func (BadRequestError) Locate ¶ added in v0.4.1
func (e BadRequestError) Locate() runtime.Frame
Locate the frame of the error.
func (BadRequestError) Pin ¶ added in v0.4.1
func (e BadRequestError) Pin(frame runtime.Frame) error
Pin the error to a caller frame.
func (BadRequestError) Unwrap ¶ added in v0.4.1
func (e BadRequestError) Unwrap() error
Unwrap the inner error.
type DatabaseQueryError ¶
type DatabaseQueryError struct { Query string // contains filtered or unexported fields }
DatabaseQueryError should be used to provide detail about a failed database query. e.g. Trying to query the database, but the database rejects the query.
func (DatabaseQueryError) Error ¶
func (e DatabaseQueryError) Error() string
func (DatabaseQueryError) Locate ¶
func (e DatabaseQueryError) Locate() runtime.Frame
Locate the frame of the error.
func (DatabaseQueryError) Pin ¶
func (e DatabaseQueryError) Pin(frame runtime.Frame) error
Pin the error to a caller frame.
func (DatabaseQueryError) Unwrap ¶
func (e DatabaseQueryError) Unwrap() error
Unwrap the inner error.
type InternalError ¶
type InternalError struct {
// contains filtered or unexported fields
}
InternalError can be used to wrap any error. e.g. Trying to generate a random UUID, but the generation failed.
func (InternalError) Error ¶
func (e InternalError) Error() string
func (InternalError) Locate ¶
func (e InternalError) Locate() runtime.Frame
Locate the frame of the error.
type NotAllowedError ¶
type NotAllowedError struct {
// contains filtered or unexported fields
}
NotAllowedError should be used when an certain action is not allowed. e.g. Someone tries to delete something, but the record has been marked as permanent.
func (NotAllowedError) Error ¶
func (e NotAllowedError) Error() string
func (NotAllowedError) Locate ¶
func (e NotAllowedError) Locate() runtime.Frame
Locate the frame of the error.
type NotFoundError ¶
type NotFoundError struct { Entity string Identifier interface{} // contains filtered or unexported fields }
NotFoundError should be used when an entity cannot be found. e.g. Someone tries to retrieve a user, but the user for the given ID does not exist in the database.
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
func (NotFoundError) Locate ¶
func (e NotFoundError) Locate() runtime.Frame
Locate the frame of the error.
type UnauthorizedError ¶
type UnauthorizedError struct {
// contains filtered or unexported fields
}
UnauthorizedError should be used when an action is performed by a user that they don't have permission to do. e.g. Someone tried to access something they were not allowed to according to a permission policy.
func (UnauthorizedError) Error ¶
func (e UnauthorizedError) Error() string
func (UnauthorizedError) Locate ¶
func (e UnauthorizedError) Locate() runtime.Frame
Locate the frame of the error.
type ValidationError ¶
type ValidationError struct {
Entity, Field string
// contains filtered or unexported fields
}
ValidationError should be used to detail what user generated information is incorrect and why. e.g. Someone set the name field for a user to be empty, but the validation requires it to be present.
func (ValidationError) Error ¶
func (e ValidationError) Error() string
func (ValidationError) Locate ¶
func (e ValidationError) Locate() runtime.Frame
Locate the frame of the error.