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
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)
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 ¶
NewCompositeHandler returns a new CompositeHandler.
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 (*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.