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" // KindUnauthentication are errors caused by an unauthenticated call KindUnauthenticated KindType = "UNAUTHENTICATED" KindUnauthorized KindType = "UNAUTHORIZED" )
Variables ¶
This section is empty.
Functions ¶
func NewMissingRequiredDependency ¶
NewMissingRequiredDependency creates a new error that indicates a missing required dependency. It should be producing at struct constructors.
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