errors

package
v0.0.0-...-08046e1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(e error) error

Cause returns the underlying cause error of the passed error if it exists.

func Details

func Details(err error) string

Details returned a formatted ErrorStack string

func ErrorStack

func ErrorStack(err error) []string

ErrorStack returns the full stack of information attached to this error.

func Newf

func Newf(format string, args ...interface{}) error

Newf creates a new raw error and trace it.

func Trace

func Trace(other error) error

Trace attach a location to the error. It should be called each time an error is returned. If the error is nil, it returns nil.

func Tracef

func Tracef(other error, format string, args ...interface{}) error

Tracef attach a location and an annotation to the error. If the error is nil it returns nil.

Types

type ConcreteUserError

type ConcreteUserError struct {
	ErrCause   error  `json:"-"`
	ErrStatus  int    `json:"-"`
	ErrCode    string `json:"code"`
	ErrMessage string `json:"message"`
}

ConcreteUserError is a concrete type that implements the UserError interface.

func Build

func Build(err UserError) *ConcreteUserError

Build constructs a ConcreteUserError from a UserError.

func (*ConcreteUserError) Cause

func (e *ConcreteUserError) Cause() error

Cause complies to the UserError interface.

func (*ConcreteUserError) Code

func (e *ConcreteUserError) Code() string

Code complies to the UserError interface.

func (*ConcreteUserError) Error

func (e *ConcreteUserError) Error() string

Error complies to the UserError and error interface.

func (*ConcreteUserError) Message

func (e *ConcreteUserError) Message() string

Message complies to the UserError interface.

func (*ConcreteUserError) Status

func (e *ConcreteUserError) Status() int

Status complies to the UserError interface.

type UserError

type UserError interface {
	Cause() error
	Status() int
	Code() string
	Message() string
	Error() string
}

UserError is the error interface that can be returned by the API

func ExtractUserError

func ExtractUserError(err error) UserError

ExtractUserError returns the underlying UserError or nil otherwise

func NewUserError

func NewUserError(
	err error,
	status int,
	code string,
	message string,
) UserError

NewUserError is an helper function to construct a new UserError.

func NewUserErrorf

func NewUserErrorf(
	err error,
	status int,
	code string,
	format string,
	args ...interface{},
) UserError

NewUserErrorf is an helper function to construct a new UserError.

Jump to

Keyboard shortcuts

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