falcon

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: MIT Imports: 1 Imported by: 4

README

Go Report Card GoDoc GoCover

Falcon

Minimal And Efficient Error Handling In Go

Simple Example

errHandler := falcon.NewErrorHandler()

errHandler.AddHandler(func(err error, data ...interface{}) interface{} {
    fmt.Println("Generic Error Occured")
    return SomeData
})

errHandler.AddHandler(func(err error, data ...interface{}) interface{} {
    fmt.Println("Error Of Type CustomErrorType Occured")
    return SomeData
}, CustomErrorType{})

SomeData := errHandler.Check(err, SomeRandomData1, SomeRandomData2)
//Data passed after the err will be passed to handlers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorHandler

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

ErrorHandler will error handle

func NewErrorHandler

func NewErrorHandler() *ErrorHandler

NewErrorHandler returnes new error handler

func (*ErrorHandler) AddHandler

func (errorHandler *ErrorHandler) AddHandler(handleFunc func(error, ...interface{}) interface{},
	errTypes ...interface{})

AddHandler adds a new error handler

func (ErrorHandler) Check

func (errorHandler ErrorHandler) Check(err error, data ...interface{}) interface{}

Check checks err

func (*ErrorHandler) Init

func (errorHandler *ErrorHandler) Init()

Init Initializes

Jump to

Keyboard shortcuts

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