Documentation
¶
Index ¶
- Variables
- func NewPossibleRowNotFoundError(err error) error
- type AuthenticationError
- type BadRequestError
- type Err
- type NotFoundError
- type PermissionsError
- type PossibleRowNotFoundError
- type Private
- type ServiceUnavailable
- type StackTraceError
- func (err *StackTraceError) Error() string
- func (err *StackTraceError) ErrorContext() map[string]interface{}
- func (err StackTraceError) Stack() []byte
- func (err *StackTraceError) StackFrames() []errors.StackFrame
- func (err *StackTraceError) WithContext(ctx map[string]interface{}) TraceFace
- func (err *StackTraceError) WithContextField(key string, value interface{}) TraceFace
- type TraceFace
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var MaxStackDepth = 50
MaxStackDepth is the maximum number of stack frames to report.
var ValidationErrorStatusCode = 422
ValidationErrorStatusCode represents the HTTP status code for ValidationError.
Functions ¶
func NewPossibleRowNotFoundError ¶
NewPossibleRowNotFoundError determines if err matches sql.ErrNoRows and returns the err wrapped in a NotFoundError, otherwise the err returned as normal.
Types ¶
type AuthenticationError ¶
type AuthenticationError struct {
Err
}
AuthenticationError represents a failure to authenticate.
func NewAuthError ¶
func NewAuthError(code int, parts ...string) AuthenticationError
NewAuthError returns a new AuthenticationError to wrap the supplied error.
func (AuthenticationError) StatusCode ¶
func (err AuthenticationError) StatusCode() int
StatusCode implements the `vc.StatusError` interface. Any AuthenticationError should return a 401 response.
type BadRequestError ¶
type BadRequestError struct {
Err
}
BadRequestError represents a bad request error.
func NewBadRequestError ¶
func NewBadRequestError(err error) BadRequestError
NewBadRequestError returns a new BadRequestError to wrap the supplied error.
func (BadRequestError) StatusCode ¶
func (err BadRequestError) StatusCode() int
StatusCode implements the `vc.StatusError` interface.
type Err ¶
type Err struct { Code int OriginalError error Description string AdditionalFields map[string]string }
Err reprents a type that contains fields for additional error metadata. This type is generally extended with more domain specific context.
func (Err) ErrorDescription ¶
ErrorDescription implements `vc.DescriptiveError` and should return a human readable description of the error.
func (Err) ErrorFields ¶
ErrorFields implements `vc.AnnotatedError` and should return a map of error details if appropriate.
func (*Err) WithFields ¶
WithFields is a chainable method that adds additional fields to the error.
type NotFoundError ¶
type NotFoundError struct {
Err
}
NotFoundError represents a resource not found.
func NewNotFoundError ¶
func NewNotFoundError(err error) NotFoundError
NewNotFoundError returns a new NotFoundError to wrap the supplied error.
func (NotFoundError) StatusCode ¶
func (err NotFoundError) StatusCode() int
StatusCode implements the `vc.StatusError` interface.
type PermissionsError ¶
type PermissionsError struct {
Err
}
PermissionsError represents a forbidden access request.
func NewPermissionsError ¶
func NewPermissionsError(code int, parts ...string) PermissionsError
NewPermissionsError returns a new PermissionsError to wrap the supplied error. The parts slice elements refer to the original error and a more detailed description respectively.
func (PermissionsError) StatusCode ¶
func (err PermissionsError) StatusCode() int
StatusCode implements the `vc.StatusError` interface.
type PossibleRowNotFoundError ¶
type PossibleRowNotFoundError struct {
Err
}
PossibleRowNotFoundError represents a resource not found.
func (PossibleRowNotFoundError) StatusCode ¶
func (err PossibleRowNotFoundError) StatusCode() int
StatusCode implements the `vc.StatusError` interface.
type Private ¶
Private masks an error with a public display message and tracking id to hide any sensitive system errors, and allow tracking of errors. Consumers should use the tracking id to link the public error to the private error message which should be logged into internal systems only.
func NewPrivate ¶
NewPrivate returns a private error wrapping the supplied error.
func (Private) LogFields ¶
LogFields implements vc.StructuredLogsError and allows for the structured logging of the tracking id, and original private errors.
func (Private) StatusCode ¶
StatusCode implements the StatusError interface.
func (*Private) WithMessage ¶
WithMessage is a chainable method to set the public message.
func (*Private) WithStatusCode ¶
WithStatusCode is a chainable method to set the status code.
type ServiceUnavailable ¶
type ServiceUnavailable struct {
}ServiceUnavailable represents a service unavailable error.
func NewServiceUnavailableError ¶
func NewServiceUnavailableError(err error) ServiceUnavailable
NewServiceUnavailableError returns a new ServiceUnavailable to wrap the supplied error.
func (ServiceUnavailable) StatusCode ¶
func (err ServiceUnavailable) StatusCode() int
StatusCode implements the `vc.StatusError` interface.
type StackTraceError ¶
type StackTraceError struct {
// contains filtered or unexported fields
}
StackTraceError wraps an error with the caller stack trace. Wrapping an error with a stack trace should occur at the boundary of your application code and external code. If an error comes from your own code, don't trace it, but if an error comes from third party code, such as opening a file, or running a db query, you should trace it so you know exactly where in your system the error occurred, and what path was taken to get there.
func (*StackTraceError) Error ¶
func (err *StackTraceError) Error() string
Error implements the error interface, with the error, type and stack trace.
func (*StackTraceError) ErrorContext ¶
func (err *StackTraceError) ErrorContext() map[string]interface{}
ErrorContext implements the api.ErrorContext interface.
func (StackTraceError) Stack ¶
func (err StackTraceError) Stack() []byte
Stack returns the callstack formatted the same way that go does in runtime/debug.Stack()
func (*StackTraceError) StackFrames ¶
func (err *StackTraceError) StackFrames() []errors.StackFrame
StackFrames returns an array of errors.StackFrames containing information about the stack.
func (*StackTraceError) WithContext ¶
func (err *StackTraceError) WithContext(ctx map[string]interface{}) TraceFace
WithContext adds metadata to a stack trace error for context.
func (*StackTraceError) WithContextField ¶
func (err *StackTraceError) WithContextField(key string, value interface{}) TraceFace
WithContextField adds a metadatum to a stack trace error for context.
type TraceFace ¶
type TraceFace interface { Error() string WithContext(map[string]interface{}) TraceFace WithContextField(string, interface{}) TraceFace ErrorContext() map[string]interface{} }
TraceFace is an interface that represents StackTraceError. By defining an interface, we're able to return a nil interface rather than a nil pointer. This allows comparison with nil, and therefore doesn't break error checking.
type ValidationError ¶
type ValidationError struct {
Err
}
ValidationError represents a validation error.
func NewSchemaValidationError ¶
func NewSchemaValidationError(schemaErrors []schema.ResultError) ValidationError
NewSchemaValidationError returns a ValidationError that contains information about every field that was invalid.
func NewValidationError ¶
func NewValidationError(err error) ValidationError
NewValidationError returns a new ValidationError to wrap the supplied error.
func (ValidationError) StatusCode ¶
func (err ValidationError) StatusCode() int
StatusCode implements the `vc.StatusError` interface. Any AuthenticationError should return a 401 response.