Documentation ¶
Index ¶
- Variables
- func IsKind(err error, kind error) bool
- func IsRootOfKind(err error, kind error) bool
- type Error
- type ErrorStack
- func Assertion(e interface{}) *ErrorStack
- func Create(e interface{}, extras ...string) *ErrorStack
- func Database(e interface{}) *ErrorStack
- func Default(e interface{}) *ErrorStack
- func Delete(e interface{}) *ErrorStack
- func Duplicated(e interface{}) *ErrorStack
- func Forbidden(e interface{}) *ErrorStack
- func MethodNotAllowed(e interface{}) *ErrorStack
- func NotFound(e interface{}) *ErrorStack
- func Unauthorized(e interface{}) *ErrorStack
- func Update(e interface{}) *ErrorStack
- func Validation(e interface{}, extras ...string) *ErrorStack
Constants ¶
This section is empty.
Variables ¶
var ErrAssertion = errors.New("Assertion")
var ErrCreate = errors.New("Cannot create record")
var ErrDatabase = errors.New("Database")
var ErrDelete = errors.New("Cannot delete record")
var ErrDuplicated = errors.New("Duplicated record")
var ErrForbidden = errors.New("Forbidden")
var ErrInternal = errors.New("Internal")
var ErrNotFound = errors.New("Record not found")
var ErrUpdate = errors.New("Cannot update record")
var ErrValidation = errors.New("Validation")
Functions ¶
func IsKind ¶
IsKind checks if an error is an error stack, and if it is, checks if the last error of the stack is of a given kind. Notice that the kind is also an error. The kind comparision is done not by the string representation of the two error kinds but direct instance comparision.
func IsRootOfKind ¶
IsRootOfKind checks if an error is an error stack, and if it is, checks if the root error of the stack is of a given kind. Notice that the kind is also an error. The kind comparision is done not by the string representation of the two error kinds but direct instance comparision.
Types ¶
type Error ¶
Error represents an application error. It does contain: - an array of previous errors, - a textual representation of the current error, - an error type that can be compared with standard errors, - an http status code.
func (Error) Error ¶
Error returns a textual representation of the error. Satisfies the standard error interface.
func (*Error) MarshalJSON ¶
MarshalJSON returns an array of bytes which contains a marshaled json version of the error. Satisfies the Marshaler interface.
func (*Error) StatusCode ¶
StatusCode returns an HTTP status code Satisfies GoKit StatusCoder interface.
type ErrorStack ¶
type ErrorStack struct {
Errors []Error
}
func Assertion ¶
func Assertion(e interface{}) *ErrorStack
func Create ¶
func Create(e interface{}, extras ...string) *ErrorStack
func Database ¶
func Database(e interface{}) *ErrorStack
func Default ¶
func Default(e interface{}) *ErrorStack
Default receives an object (error or string) and creates an ErrorStack. If object is already an ErrorStack then it appends the current error to the existing stack.
func Delete ¶
func Delete(e interface{}) *ErrorStack
func Duplicated ¶
func Duplicated(e interface{}) *ErrorStack
func Forbidden ¶
func Forbidden(e interface{}) *ErrorStack
func MethodNotAllowed ¶
func MethodNotAllowed(e interface{}) *ErrorStack
func NotFound ¶
func NotFound(e interface{}) *ErrorStack
func Unauthorized ¶
func Unauthorized(e interface{}) *ErrorStack
func Update ¶
func Update(e interface{}) *ErrorStack
func Validation ¶
func Validation(e interface{}, extras ...string) *ErrorStack
func (ErrorStack) Error ¶
func (e ErrorStack) Error() string
Error returns a textual representation of the error. Satisfies the standard error interface.
func (*ErrorStack) MarshalJSON ¶
func (e *ErrorStack) MarshalJSON() ([]byte, error)
MarshalJSON returns an array of bytes which contains a marshaled json version of the error. Satisfies the Marshaler interface.
func (*ErrorStack) StatusCode ¶
func (e *ErrorStack) StatusCode() int
StatusCode returns an HTTP status code Satisfies GoKit StatusCoder interface.
func (*ErrorStack) UnmarshalJSON ¶
func (e *ErrorStack) UnmarshalJSON(data []byte) error
UnmarshalJSON allows to unmarshal an ErrorStack from his json representation.