Documentation ¶
Overview ¶
Package errio contains custom error types to easily transfer errors between applications and output them to the user in a consistent way.
Index ¶
- func CaptureError(err error, tags map[string]string) (string, chan error)
- func CaptureErrorAndWait(err error, tags map[string]string) string
- func Error(err error) error
- func IsKnown(err error) bool
- func NewException(err error, stacktrace *raven.Stacktrace) *raven.Exception
- func StatusError(err error) error
- type ErrorCode
- func (c ErrorCode) Error(message string) PublicError
- func (c ErrorCode) ErrorPref(message string) func(args ...interface{}) PublicError
- func (c ErrorCode) Errorf(message string, args ...interface{}) PublicError
- func (c ErrorCode) StatusError(message string, status int) PublicStatusError
- func (c ErrorCode) StatusErrorf(message string, status int, args ...interface{}) PublicStatusError
- type Namespace
- type PublicError
- type PublicStatusError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureError ¶
CaptureError captures an error and sends it to Sentry.
func CaptureErrorAndWait ¶
CaptureErrorAndWait captures an error and sends it to Sentry and wait for that process to be finished.
func Error ¶
Error can be called to on any error to convert it to a PublicError if it is not already. If it is not yet a PublicError, an UnexpectedError is returned
func NewException ¶
func NewException(err error, stacktrace *raven.Stacktrace) *raven.Exception
NewException returns a *raven.Exception for an error from this package. In contrary to raven.NewException, this function tries to retrieve the error type from the typer interface.
func StatusError ¶
StatusError can be called to on any error to convert it to a PublicStatusError if it is not already. If it is not yet a PublicError, an UnexpectedError is returned
Types ¶
type ErrorCode ¶
ErrorCode contains a code that should be unique to the namespace it belongs to
func (ErrorCode) Error ¶
func (c ErrorCode) Error(message string) PublicError
Error returns a PublicError with the given code and message
func (ErrorCode) ErrorPref ¶
func (c ErrorCode) ErrorPref(message string) func(args ...interface{}) PublicError
ErrorPref returns a function that can be called with arguments to create a formatted error message
func (ErrorCode) Errorf ¶
func (c ErrorCode) Errorf(message string, args ...interface{}) PublicError
Errorf works like fmt.Errorf to create an Error.
func (ErrorCode) StatusError ¶
func (c ErrorCode) StatusError(message string, status int) PublicStatusError
StatusError creates a new PublicStatusError
func (ErrorCode) StatusErrorf ¶
func (c ErrorCode) StatusErrorf(message string, status int, args ...interface{}) PublicStatusError
StatusErrorf works like fmt.Errorf to create a StatusError
type Namespace ¶
type Namespace string
Namespace is a container for different errors and is used to distinguish between error codes. Using different namespaces helps you to keep error codes unique throughout your codebase. Typically, namespaces will carry the name of their package name or file name (without the .go part).
type PublicError ¶
type PublicError struct { Namespace Namespace `json:"namespace,omitempty"` Code string `json:"code"` Message string `json:"message"` }
PublicError is a wrapper around an error code and a error message. This allows clear error messaging and trace ability.
func UnexpectedError ¶
func UnexpectedError(err error) PublicError
UnexpectedError represents an error that we did not expect. Unexpected errors are reported and logged.
func (PublicError) Append ¶
func (e PublicError) Append(errs ...error) PublicError
Append appends multiple errors to an PublicError.
func (PublicError) Error ¶
func (e PublicError) Error() string
PublicError implements the error interface.
func (PublicError) Type ¶
func (e PublicError) Type() string
Type returns the type of the error as to be reported to Sentry.
type PublicStatusError ¶
type PublicStatusError struct { PublicError `json:"error"` StatusCode int `json:"-"` }
PublicStatusError represents an http error. It contains an HTTP status code and can be json encoded in an HTTP response.
func UnexpectedStatusError ¶
func UnexpectedStatusError(err error) PublicStatusError
UnexpectedStatusError is an error we did not expect, with http.StatusInternalServerError attached to it.
func Wrap ¶
func Wrap(base PublicStatusError, errs ...error) PublicStatusError
Wrap wraps multiple errors with a PublicStatusError.
func (PublicStatusError) Append ¶
func (e PublicStatusError) Append(errs ...error) PublicStatusError
Append appends multiple errors to a PublicStatusError
func (PublicStatusError) Error ¶
func (e PublicStatusError) Error() string
Error implements the error interface.
func (PublicStatusError) Type ¶
func (e PublicStatusError) Type() string
Type returns the type of the error as to be reported to Sentry.