errors

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultErrorMessage = "unknown error"

Variables

This section is empty.

Functions

func GetOriginalError

func GetOriginalError(err error) error

GetOriginalError returns original error. If err isn't an instance of 'fundamental' type, passed error will be returned

func New

func New(msg string, opts ...Option) error

New creates a new error with passed message

func Wrap

func Wrap(err error, opts ...Option) error

Wrap wraps passed error and applies options

Types

type ErrorType

type ErrorType int
const (
	UndefinedError ErrorType = iota
	UserError
	AppError
)

func GetErrorType

func GetErrorType(err error) (t ErrorType, ok bool)

type Option

type Option func(*fundamental)

func WithMsg

func WithMsg(msg string, a ...interface{}) Option

WithMsg sets message. It supports formatting

func WithOriginalError

func WithOriginalError() Option

WithOriginalError exposes original error for printing

func WithType

func WithType(t ErrorType) Option

WithType sets passed Error Type

func WithTypeIfNotSet

func WithTypeIfNotSet(t ErrorType) Option

WithTypeIfNotSet sets passed Error Type if current Error Type is UndefinedError

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL