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 ¶
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:
Click to show internal directories.
Click to hide internal directories.