Documentation ¶
Overview ¶
Package errors holds some of the defined wrappers to handle specific type of errors.
Index ¶
- Constants
- func FromStatusCode(statusCode int, format string, args ...interface{}) error
- func IsBadParameterError(err error) (bool, error)
- func IsConversionError(err error) (bool, error)
- func IsDataConflictError(err error) (bool, error)
- func IsForbiddenError(err error) (bool, error)
- func IsInternalError(err error) (bool, error)
- func IsNotFoundError(err error) (bool, error)
- func IsUnauthorizedError(err error) (bool, error)
- func IsVersionConflictError(err error) (bool, error)
- type BadParameterError
- type ConversionError
- type DataConflictError
- type ForbiddenError
- type InternalError
- type NotFoundError
- type UnauthorizedError
- type VersionConflictError
Constants ¶
const ( UNAUTHORIZED_CODE_TOKEN_DEPROVISIONED = 1 UNAUTHORIZED_CODE_TOKEN_REVOKED = 2 )
const (
ErrInternalDatabase = "database_error"
)
Constants that can be used to identify internal server errors
Variables ¶
This section is empty.
Functions ¶
func FromStatusCode ¶
FromStatusCode returns an error from the given HTTP status code, using the message and args
func IsBadParameterError ¶
IsBadParameterError returns true if the cause of the given error can be converted to an BadParameterError, which is returned as the second result.
func IsConversionError ¶
IsConversionError returns true if the cause of the given error can be converted to an ConversionError, which is returned as the second result.
func IsDataConflictError ¶
IsDataConflictError returns true if the cause of the given error can be converted to an IsDataConflictError, which is returned as the second result.
func IsForbiddenError ¶
IsForbiddenError returns true if the cause of the given error can be converted to an ForbiddenError, which is returned as the second result.
func IsInternalError ¶
IsInternalError returns true if the cause of the given error can be converted to an InternalError, which is returned as the second result.
func IsNotFoundError ¶
IsNotFoundError returns true if the cause of the given error can be converted to an NotFoundError, which is returned as the second result.
func IsUnauthorizedError ¶
IsUnauthorizedError returns true if the cause of the given error can be converted to an UnauthorizedError, which is returned as the second result.
func IsVersionConflictError ¶
IsVersionConflictError returns true if the cause of the given error can be converted to an VersionConflictError, which is returned as the second result.
Types ¶
type BadParameterError ¶
type BadParameterError struct {
// contains filtered or unexported fields
}
BadParameterError means that a parameter was not as required
func NewBadParameterError ¶
func NewBadParameterError(param string, actual interface{}) BadParameterError
NewBadParameterError returns the custom defined error of type BadParameterError.
func NewBadParameterErrorFromString ¶
func NewBadParameterErrorFromString(param string, actual interface{}, errorMessage string) BadParameterError
NewBadParameterErrorFromString returns the custom defined error of type BadParameterError.
func (BadParameterError) Error ¶
func (err BadParameterError) Error() string
Error implements the error interface
func (BadParameterError) Expected ¶
func (err BadParameterError) Expected(expected interface{}) BadParameterError
Expected sets the optional expectedValue parameter on the BadParameterError
type ConversionError ¶
type ConversionError struct {
// contains filtered or unexported fields
}
ConversionError error means something went wrong converting between different representations
func NewConversionError ¶
func NewConversionError(msg string) ConversionError
NewConversionError returns the custom defined error of type NewConversionError.
type DataConflictError ¶
type DataConflictError struct {
// contains filtered or unexported fields
}
DataConflictError means that the version was not as expected in an update operation
func NewDataConflictError ¶
func NewDataConflictError(msg string) DataConflictError
NewDataConflictError returns the custom defined error of type NewDataConflictError.
type ForbiddenError ¶
type ForbiddenError struct {
// contains filtered or unexported fields
}
ForbiddenError means that the operation is forbidden
func NewForbiddenError ¶
func NewForbiddenError(msg string) ForbiddenError
NewForbiddenError returns the custom defined error of type ForbiddenError.
type InternalError ¶
type InternalError struct {
Err error
}
InternalError means that the operation failed for some internal, unexpected reason
func NewInternalError ¶
func NewInternalError(err error) InternalError
NewInternalError returns the custom defined error of type InternalError.
func NewInternalErrorFromString ¶
func NewInternalErrorFromString(errorMessage string) InternalError
NewInternalErrorFromString returns the custom defined error of type InternalError.
func (InternalError) Error ¶
func (ie InternalError) Error() string
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError means the object specified for the operation does not exist
func NewNotFoundError ¶
func NewNotFoundError(entity string, value string) NotFoundError
NewNotFoundError returns the custom defined error of type NewNotFoundError.
func NewNotFoundErrorFromString ¶
func NewNotFoundErrorFromString(errorMessage string) NotFoundError
NewNotFoundErrorFromString returns the custom defined error of type NewNotFoundError.
func NewNotFoundErrorWithKey ¶
func NewNotFoundErrorWithKey(entity string, key, value string) NotFoundError
NewNotFoundErrorWithKey returns the custom defined error of type NewNotFoundError and custom key name (instead of the default 'ID")
func (NotFoundError) Error ¶
func (err NotFoundError) Error() string
type UnauthorizedError ¶
type UnauthorizedError struct { // contains filtered or unexported fields }
UnauthorizedError means that the operation is unauthorized
func NewUnauthorizedError ¶
func NewUnauthorizedError(msg string) UnauthorizedError
NewUnauthorizedError returns the custom defined error of type UnauthorizedError.
func NewUnauthorizedErrorWithCode ¶
func NewUnauthorizedErrorWithCode(msg string, code int) UnauthorizedError
type VersionConflictError ¶
type VersionConflictError struct {
// contains filtered or unexported fields
}
VersionConflictError means that the version was not as expected in an update operation
func NewVersionConflictError ¶
func NewVersionConflictError(msg string) VersionConflictError
NewVersionConflictError returns the custom defined error of type VersionConflictError.