Documentation
¶
Index ¶
- Variables
- func Trace(err error) error
- type Builder
- type Error
- func (e *Error) AddMetadata(key string, value interface{}) *Error
- func (e *Error) Code() string
- func (e *Error) Copy(args ...SetOptionFn) *Error
- func (e *Error) Error() string
- func (e *Error) Is(err error) bool
- func (e *Error) Message() string
- func (e *Error) Metadata() map[string]interface{}
- func (e *Error) Namespace() string
- func (e *Error) Trace(args ...SetOptionFn) *Error
- func (e *Error) Traces() []string
- func (e *Error) Unwrap() error
- func (e *Error) Wrap(err error) *Error
- type SetOptionFn
- func AddMetadata(key string, value interface{}) SetOptionFn
- func Errorf(msg string, args ...interface{}) SetOptionFn
- func FallbackError(err *Error) SetOptionFn
- func SkipTrace(skip int) SetOptionFn
- func Source(err error) SetOptionFn
- func WithMetadata(metadata map[string]interface{}) SetOptionFn
- func WithNamespace(namespace string) SetOptionFn
Constants ¶
This section is empty.
Variables ¶
var DuplicateFallbackError = NewError("ERR_1", "Cannot create new Error that has same code with Fallback Error", WithNamespace(pkgNamespace))
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is an error builder with template namespace. All error produced will have a namespace
func NewBuilder ¶
func NewBuilder(namespace string, args ...SetOptionFn) *Builder
func (*Builder) CopyError ¶ added in v0.2.0
func (b *Builder) CopyError(err *Error, args ...SetOptionFn) *Error
CopyError take error input and override the namespace
func (*Builder) FallbackError ¶
FallbackError is getter function to retrieve FallbackError value
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is an immutable object. print error meaningful message and stack trace for easier error tracing
func InternalError ¶
func InternalError() *Error
func NewError ¶
func NewError(code string, message string, args ...SetOptionFn) *Error
NewError initiates a new error instance
func (*Error) AddMetadata ¶ added in v0.5.0
AddMetadata copy existing error and set new metadata
func (*Error) Copy ¶
func (e *Error) Copy(args ...SetOptionFn) *Error
Copy duplicate error traces. Available options is WithNamespace, WithMetadata and CopySource
func (*Error) Error ¶
Error implement standard go error interface. If source error is exists then it will print error cause
func (*Error) Is ¶
Is implements function that will be called by errors.Is for error comparison. Actual error namespace and code value must equal with Expected ones
func (*Error) Trace ¶
func (e *Error) Trace(args ...SetOptionFn) *Error
type SetOptionFn ¶
type SetOptionFn = func(*options)
func AddMetadata ¶ added in v0.2.0
func AddMetadata(key string, value interface{}) SetOptionFn
func Errorf ¶ added in v0.3.0
func Errorf(msg string, args ...interface{}) SetOptionFn
func FallbackError ¶
func FallbackError(err *Error) SetOptionFn
func SkipTrace ¶
func SkipTrace(skip int) SetOptionFn
func Source ¶ added in v0.2.1
func Source(err error) SetOptionFn
func WithMetadata ¶
func WithMetadata(metadata map[string]interface{}) SetOptionFn
func WithNamespace ¶
func WithNamespace(namespace string) SetOptionFn