Documentation
¶
Index ¶
Constants ¶
const ( // CodeUnknown is the default code returned when the application doesn't attach any code into the error. CodeUnknown CodeType = "UNKNOWN" // KindUnexpected is the default kind returned when the application doesn't attach any kind into the error. KindUnexpected KindType = "UNEXPECTED" // KindConflict are errors caused by requests with data that conflicts with the current state of the system. KindConflict KindType = "CONFLICT" // KindInternal are errors caused by some internal fail like failed IO calls or invalid memory states. KindInternal KindType = "INTERNAL" // KindInvalidInput are errors caused by some invalid values on the input. KindInvalidInput KindType = "INVALID_INPUT" // KindNotFound are errors caused by any required resources that not exists on the data repository. KindNotFound KindType = "NOT_FOUND" // KindUnauthenticated are errors caused by an unauthenticated call. KindUnauthenticated KindType = "UNAUTHENTICATED" KindUnauthorized KindType = "UNAUTHORIZED" // KindResourceExhausted indicates some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. KindResourceExhausted KindType = "RESOURCE_EXHAUSTED" )
Variables ¶
var ( // ErrResourceNotFound indicates that a desired resource was not found. ErrResourceNotFound error = New("resource not found").WithKind(KindNotFound).WithCode("RESOURCE_NOT_FOUND") // ErrNotImplemented indicates that a given feature is not implemented yet. ErrNotImplemented error = New("feature not implemented yet").WithCode("FEATURE_NOT_IMPLEMENTED") // ErrMock is a fake mocked that should be used in test scenarios. ErrMock error = New("mocked error").WithCode("MOCKED_ERROR") )
Functions ¶
func NewMissingRequiredDependency ¶
NewMissingRequiredDependency creates a new error that indicates a missing required dependency. It should be producing at struct constructors.
func NewValidationError ¶ added in v0.4.0
NewValidationError creates a Validation error.
Types ¶
type CustomError ¶
type CustomError struct {
// contains filtered or unexported fields
}
CustomError is a structure that encodes useful information about a given error. It's supposed to flow within the application in detriment of the the default golang error, since its Kind and Code attributes are the keys to express its semantic and uniqueness, respectively. It should be generated once by the peace of code that found the error (because it's where we have more context about the error), and be by passed to the upper layers of the application.
func New ¶
func New(message string, args ...interface{}) CustomError
New returns a new instance of CustomError with the given message.
func (CustomError) WithCode ¶
func (ce CustomError) WithCode(code CodeType) CustomError
WithCode return a copy of the CustomError with the given CodeType filled.
func (CustomError) WithKind ¶
func (ce CustomError) WithKind(kind KindType) CustomError
WithKind return a copy of the CustomError with the given KindType filled.
func (CustomError) WithRootError ¶
func (ce CustomError) WithRootError(err error) CustomError
WithRootError returns a copy of the CustomError with the RootError filled.