Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InternalErrorMiddleware ¶
func InternalErrorMiddleware(logger log.Logger) endpoint.Middleware
InternalErrorMiddleware is a convenience middleware which can be used in combination with panics. After data is sanitized and validated, services can expect to get reasonable valid data passed (e.g. object not nil, string not empty, ...). With this middleware in place the service can throw an exception with a precond.PreconditionError as payload. This middleware will catch that and translate it into an application level PreconditionError. All other detected panics will be converted into an InternalServerError. In both cases it is most likely that there is an error withing the application or a library. Long story short, this is about failing early in non recoverable situations.
Types ¶
type InternalServerError ¶
type InternalServerError struct { // contains filtered or unexported fields } // Unknown internal error, most likely a bug in a service or a library
func NewInternalServerError ¶
func NewInternalServerError(err error) *InternalServerError
type MappingError ¶
type MappingError struct {
// contains filtered or unexported fields
}
MappingError indicates that mapping a DTO to an entity failed. Can be used by endpoint.Endpoint
type PreconditionError ¶
type PreconditionError struct { // contains filtered or unexported fields } // Precondition not met, most likely a bug in a service (service)
type ResourceExistsError ¶
type ResourceExistsError struct {
// contains filtered or unexported fields
}
Resource which should be created exists already. Can be used by endpoint.Endpoint or a Service. E.g. lock
type ResourceNotFoundError ¶
type ResourceNotFoundError struct { // contains filtered or unexported fields } // Can be thrown before or by a service call
func NewResourceConflictError ¶
func NewResourceConflictError(msg string) *ResourceNotFoundError
func NewResourceExistsError ¶
func NewResourceExistsError(resource string, name string) *ResourceNotFoundError
func NewResourceNotFoundError ¶
func NewResourceNotFoundError(resource string, name string) *ResourceNotFoundError
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError indicates that a DTO validations failed. Can be used by http.EncodeResponseFunc implementations.