Documentation ¶
Overview ¶
Package errtag facilitates tagging error chains with distinct categories. The whole point of tagging errors with categories is to facilitate easier casting from errors to HTTP status codes at the transport layer. It also means you don't need to use explicit, manually defined custom errors for common things such as `sql.ErrNoRows`. You can decorate an error with metadata and tag it as a "not found" kind of error and at the transport layer, handle all errors with a unified error handler that can automatically set the HTTP status code.
An error tag is any type which satisfies the interface `Tag() string`. Included in the library is a set of commonly used kinds of problem that can occur in most applications. These are based on gRPC status codes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlreadyExists ¶
type AlreadyExists struct{} // The entity that a client attempted to create already exists.
func (AlreadyExists) Tag ¶
func (AlreadyExists) Tag() string
type Internal ¶
type Internal struct{} // Internal errors. This means that some invariants expected by the underlying system have been broken. This error code is reserved for serious errors.
type InvalidArgument ¶
type InvalidArgument struct{} // The client specified an invalid argument.
func (InvalidArgument) Tag ¶
func (InvalidArgument) Tag() string
type PermissionDenied ¶
type PermissionDenied struct{} // The caller does not have permission to execute the specified operation.
func (PermissionDenied) Tag ¶
func (PermissionDenied) Tag() string
type Unauthenticated ¶
type Unauthenticated struct{} // The request does not have valid authentication credentials for the operation.
func (Unauthenticated) Tag ¶
func (Unauthenticated) Tag() string