Documentation ¶
Index ¶
- Constants
- Variables
- func AppendError(err, errn error) error
- func GetErrs(err error) []error
- func GetHTTPDetails(err error) (code int, msg string)
- func IsOfType(terr, err error) bool
- func Len(err error) int
- func Mask(err error) error
- func New(format string, args ...interface{}) error
- func NewHTTPError(c int, err error) error
- func NewTypedError(terr, err error) error
- func StackTrace(err error) string
- func WithStackTrace(err error) error
- type Error
- type TypedError
Constants ¶
const ErrUnknown = Error("unknown error")
ErrUnknown is an unknown error type
Variables ¶
var MaskErrs = true
MaskErrs this is a compile time flag to indicate whether to mask errors that can leak private or sensitive information. IMPORTANT!!! DO NOT CHANGE AT RUNTIME in production code.
Functions ¶
func AppendError ¶
AppendError returns a new listError if errn == nil, return err if err is of type listError and if errn is of type listerror, append errn errors to err and return err
func GetHTTPDetails ¶
GetHTTPDetails returns a http code and message default http code is 500.
func Len ¶
Len returns the total number of errors if err is listError, return len(listError.errs) if err == nil, return 0 else return 1
func New ¶
New returns a new error with message passed. if args are passed, we will format the message with args Example: New("some error") returns error with exact string passed New("some error: %v", "some context") returns error with message "some error: some context"
func NewTypedError ¶
NewTypedError returns a new error of type typedError
func StackTrace ¶
StackTrace returns the stack trace attached to the error if any
func WithStackTrace ¶
WithStackTrace attaches stack trace to error. Note: if the err already holds a stack trace, that trace will be replace with latest
Types ¶
type Error ¶
type Error string
Error is a string that implements error this will have interesting side effects of having constant errors
type TypedError ¶
TypedError can be implemented by any type error