errors

package module
v0.0.0-...-5230ee4 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2017 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(w io.Writer)

SetLogger sets the default output for error logging. If this function is not called, errors are discarted

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error describes a failed action with an status code

func New

func New(message string) *Error

New returns an error with the given message, and a zero status code

func WithMessage

func WithMessage(message string, code int, err error) *Error

WithMessage anotates the error with an optional

func WithStatus

func WithStatus(code int, err error) *Error

WithStatus annotates a new error with an status code

func (*Error) Code

func (e *Error) Code() int

Code returns the status code of the error

func (*Error) Error

func (e *Error) Error() string

Error returns the message of the error plus its status code

func (*Error) MarshalJSON

func (e *Error) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler interface

func (*Error) WithStatus

func (e *Error) WithStatus(status int) *Error

WithStatus sets the given status code of this error

type StackError

type StackError struct {
	// contains filtered or unexported fields
}

StackError contains an error message with an status and the callees stack

func WithStack

func WithStack(message string, status int, err error) *StackError

WithStack returns an error annotated with the stacktrace

func (*StackError) Code

func (s *StackError) Code() int

Code returns the status code of the error

func (*StackError) Error

func (s *StackError) Error() string

Error returns the annotated error with its status code and the stacktrace.

func (StackError) Format

func (s StackError) Format(st fmt.State, verb rune)

func (StackError) StackTrace

func (s StackError) StackTrace() stackTrace

func (*StackError) WithStatus

func (s *StackError) WithStatus(status int)

WithStatus sets the given status to this error

Jump to

Keyboard shortcuts

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