Documentation ¶
Index ¶
- func InternalErrorMiddleware() endpoint.Middleware
- type AppError
- type BadRequestError
- type InternalServerError
- type KubernetesError
- type MappingError
- type PreconditionError
- type ResourceExistsError
- type ResourceNotFoundError
- type UnprocessableEntityError
- type UnsupportedMediaTypeError
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InternalErrorMiddleware ¶
func InternalErrorMiddleware() 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 within the application or a library. Long story short, this is about failing early in non recoverable situations.
Types ¶
type BadRequestError ¶
type BadRequestError struct {
// contains filtered or unexported fields
}
type InternalServerError ¶
type InternalServerError struct { // contains filtered or unexported fields } // Unknown internal error, most likely a bug in a service or a library
type KubernetesError ¶
type KubernetesError struct {
// contains filtered or unexported fields
}
func (*KubernetesError) Body ¶
func (k *KubernetesError) Body() []byte
func (*KubernetesError) Cause ¶
func (k *KubernetesError) Cause() error
func (*KubernetesError) Error ¶
func (k *KubernetesError) Error() string
func (*KubernetesError) StatusCode ¶
func (k *KubernetesError) StatusCode() int
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
type UnprocessableEntityError ¶
type UnprocessableEntityError struct {
// contains filtered or unexported fields
}
type UnsupportedMediaTypeError ¶
type UnsupportedMediaTypeError struct {
// contains filtered or unexported fields
}
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError indicates that a DTO validations failed. Can be used by http.EncodeResponseFunc implementations.