errors

package
v0.0.0-...-d7d6a54 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Message  string
	Err      error
	Code     ErrorCode
	Severity ErrorSeverity
}

Error is a wrapper for an error value with added context.

func E

func E(args ...interface{}) *Error

E creates a new error with the given args Will panic if an arg not supported by Error is passed

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the wrapped error.

type ErrorCode

type ErrorCode int
const (
	CodeUnexpected ErrorCode = http.StatusInternalServerError
	CodeNotFound   ErrorCode = http.StatusNotFound
	CodeBadValue   ErrorCode = http.StatusBadRequest
)

HTTP status codes used to identify errors.

func Code

func Code(err error) ErrorCode

Code returns the errors code. If it does not exist (which means err is not a pointer to Error) CodeUnexpected will be returned. If the code exists but is 0, the wrapped error's code will be returned.

type ErrorSeverity

type ErrorSeverity int

ErrorSeverity is used to classify the severity of an error. The zero value is SeverityErr.

const (
	SeverityErr ErrorSeverity = iota
	SeverityWarn
)

Severity levels

Jump to

Keyboard shortcuts

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