errhandler

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 1 Imported by: 1

Documentation

Overview

Package errhandler defines a Handler interface for handling errors. When developing an API you can implement this interface if you'd like to use an error tracking service like Sentry.

To use an error handler in your API, call errhandler.Set() as part of your middleware stack. You'll need to write a struct which implements the errhandler.Handler interface. Your HandleError method on the struct should contain all integration-specific logic to deal with the error, such as dispatching it to Sentry.

When calling apio.Error(), if a Handler exists in the provided context, HandleError() will be called.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set

Set the error handler in context so that apio.Error() will log errors to it.

Types

type Handler

type Handler interface {
	HandleError(err error)
}

Handler is an error handler which is called when apio.Error() is called in APIs.

func Get

func Get(ctx context.Context) Handler

Get retrieves an error handler from context. It returns nil if it hasn't been set.

Jump to

Keyboard shortcuts

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