emperror

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2017 License: MIT Imports: 2 Imported by: 197

README

Emperror

Build Status Go Report Card GoDoc

The Emperor takes care of all errors personally.

Development

The project requires Glide to install dependencies.

$ make dep

When all coding and testing is done, please run the test suite:

$ make check

License

The MIT License (MIT). Please see License File for more information.

Documentation

Overview

Package emperror provides error handling solutions to applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleIfErr added in v0.1.1

func HandleIfErr(handler Handler, err error)

HandleIfErr handles an error whenever it occures.

func HandleRecover added in v0.1.1

func HandleRecover(handler Handler)

HandleRecover recovers from a panic and handles the error.

go emperror.HandleRecover(errorHandler)

func Recover added in v0.1.1

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

Recover accepts a recovered panic (if any) and converts it to an error (if necessary).

Types

type CompositeHandler

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

CompositeHandler allows an error to be processed by multiple handlers.

func (*CompositeHandler) Handle

func (h *CompositeHandler) Handle(err error)

Handle goes through the handlers and call each of them for the error.

type Handler

type Handler interface {
	// Handle processes an error.
	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 NewCompositeHandler

func NewCompositeHandler(handlers ...Handler) Handler

NewCompositeHandler returns a new CompositeHandler.

func NewLogHandler

func NewLogHandler(l logger) 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 logger 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. Can be used as a fallback.

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 throws every error away.

func NewTestHandler

func NewTestHandler() *TestHandler

NewTestHandler returns a new TestHandler.

func (*TestHandler) Errors

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

Errors returns all the handled errors.

func (*TestHandler) Handle

func (h *TestHandler) Handle(err error)

Handle saves the error in a list.

func (*TestHandler) Last

func (h *TestHandler) Last() error

Last returns the last handled error.

Directories

Path Synopsis
Package airbrake provides Airbrake integration.
Package airbrake provides Airbrake integration.
Package bugsnag provides Bugsnag integration.
Package bugsnag provides Bugsnag integration.

Jump to

Keyboard shortcuts

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