errors

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2017 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package errors extends the errors package in the stdlib.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Recover

func Recover(r interface{}) (err error)

Recover accepts a recovered panic (if any) and returns it as an error.

Types

type Handler

type Handler interface {
	Handle(err error)
}

Handler is responsible for handling an error.

This interface allows libraries to decouple from logging solutions. In most cases the implementation will provide some log functionalities though.

func NewLogHandler

func NewLogHandler(logger errorLogger) Handler

NewLogHandler returns a new LogHandler.

func NewNullHandler

func NewNullHandler() Handler

NewNullHandler returns a new NullHandler.

type LogHandler

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

LogHandler accepts an errorLogger instance and logs an error.

Compatible with most level-based loggers.

func (*LogHandler) Handle

func (h *LogHandler) Handle(err error)

Handle takes care of an error by logging it.

type NullHandler

type NullHandler struct{}

NullHandler throws every error away.

func (*NullHandler) Handle

func (h *NullHandler) Handle(err error)

Handle does the actual throwing away.

type TestHandler

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

TestHandler is a test implementation of errors.Handler

func NewTestHandler

func NewTestHandler() *TestHandler

NewTestHandler returns a new LogHandler.

func (*TestHandler) Errors

func (h *TestHandler) Errors() []error

Errors returns the list of handled errors.

func (*TestHandler) Handle

func (h *TestHandler) Handle(err error)

Handle takes care of an error by logging it.

func (*TestHandler) Last

func (h *TestHandler) Last() error

Last returns the last error (if any).

Jump to

Keyboard shortcuts

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