errors

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2017 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(params HandlerParams) emperror.Handler

NewHandler returns a new error handler.

Types

type HandlerParams

type HandlerParams struct {
	dig.In

	Logger   log.Logger   `optional:"true"`
	Handlers HandlerStack `optional:"true"`
}

HandlerParams provides a set of dependencies for an error handler constructor.

type HandlerStack

type HandlerStack []emperror.Handler

HandlerStack can be used to collect multiple handlers in a single dependecy which can be injected into the main error handler constructor.

Example
package main

import (
	"github.com/goph/emperror/airbrake"
	"github.com/goph/fxt/errors"

	airbrakefx "github.com/goph/fxt/errors/airbrake"
	"go.uber.org/dig"
)

func main() {
	dic := dig.New()

	// Provide airbrake config.
	dic.Provide(func() *airbrakefx.Config {
		config := airbrakefx.NewConfig(1, "key")

		return config
	})

	// Provide the airbrake handler itself
	dic.Provide(airbrakefx.NewHandler)

	// Collect all handlers and provide the HandlerStack
	dic.Provide(func(ah *airbrake.Handler) errors.HandlerStack {
		return errors.HandlerStack{ah}
	})

	// The main error constructor will fetch the handler stack
	dic.Provide(errors.NewHandler)

}
Output:

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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