errors

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: MIT Imports: 9 Imported by: 0

README

Error Handling (sentry)

  • Each microservice need to expose "/health" and return with http 200, this is important for the load balancing of the API gateway
  • Unhandled exception handling ("in the wild")
  • Frontend Application
  • Returning 5xx to client (can indicate operations issues)
  • Depending on application logic (additional errors; cases that should not happen; security)
  • Implausible responses from upstream services (e.g. after validation of result from external API)

Environment based configuration

  • SENTRY_DSN
    • URL of the sentry DSN
  • SENTRY_ENVIRONMENT
    • Environment of sentry reported in the dashboard
  • SENTRY_RELEASE
    • Name of the release e.g. git commit or similar

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleError

func HandleError(rp interface{}, handlerName string, w http.ResponseWriter, r *http.Request)

HandleError reports the passed error to sentry

func HandleRequest

func HandleRequest(handlerName string, w http.ResponseWriter, r *http.Request)

HandleRequest should be called with defer to recover panics in request handlers

func HandleWithCtx

func HandleWithCtx(ctx context.Context, handlerName string)

HandleWithCtx should be called with defer to recover panics in goroutines

func Handler

func Handler() func(http.Handler) http.Handler

Handler implements a panic recovering middleware

func New

func New(text string) error

New returns an error that formats as the given text.

func WrapWithExtra

func WrapWithExtra(err error, extraInfo map[string]interface{}) error

WrapWithExtra adds extra data to an error before reporting to Sentry

Types

type PanicWrap

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

PanicWrap wraps a panic for HandleRequest

Jump to

Keyboard shortcuts

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