Documentation ¶
Index ¶
- func As(err error, target interface{}) bool
- func Errorf(kind Kind, format string, args ...interface{}) error
- func IsKind(err error, kind Kind) bool
- func New(kind Kind, msg string) error
- func ToUnderScore(name string) string
- func Unwrap(err error) error
- func WithFieldViolations(kind Kind, msg string, fieldViolations []FieldViolation) error
- func WithValidateError(err error) error
- func Wrap(err error, kind Kind, msg string) error
- func Wrapf(err error, kind Kind, format string, args ...interface{}) error
- type Error
- type FieldViolation
- type Kind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶
As finds the first error in err's chain that matches target, and if so, sets target to that error value and return true.
func Errorf ¶
Errorf formats according to a format specifier and return an unknown error with the string.
func New ¶
New returns an error with the supplied kind and message. If message is empty, a default message, for the error kind will be used.
func ToUnderScore ¶
ToUnderScore converts CamalCase to under_score case Source: https://gist.github.com/zxh/cee082053aa9674812e8cd4387088301
func Unwrap ¶
Unwrap returns the result of calling the Unwrap method on err, if err's type contains an Unwrap method returning error. Otherwise, Unwrap returns nil.
Same as Go's errors.Unwrap.
func WithFieldViolations ¶
func WithFieldViolations(kind Kind, msg string, fieldViolations []FieldViolation) error
WithFieldViolations returns an error with supplied field violations.
func WithValidateError ¶
WithValidateError maps a Validate error into an internal error representation.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is an internal errors with stacktrace. It can be converted to a HTTP response.
func (*Error) FieldViolations ¶
func (e *Error) FieldViolations() []FieldViolation
FieldViolations returns a structure that represents field validation errors.
type FieldViolation ¶
FieldViolation is a struct for providing field error details in HTTP error. It matches the same struct in errdetails package.
type Kind ¶
type Kind string
Kind is the kind of error.
const ( ErrorReadConfig Kind = "config read error" ErrorParseConfig Kind = "config parse error" ErrorNotImplemented Kind = "not implement" ErrorCanceled Kind = "canceled" ErrorUnknown Kind = "unknown error" ErrorInvalidArgument Kind = "invalid argument" ErrorDeadlineExceeded Kind = "deadline exceeded" ErrorNotFound Kind = "entity not found" ErrorAlreadyExists Kind = "already exists" )
Error kinds.