errors

package
v0.1.47 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: MIT Imports: 13 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 ContextTransfer added in v0.1.17

func ContextTransfer(ctx, targetCtx context.Context) context.Context

ContextTransfer copies error handling related information from one context to another.

func Handle added in v0.1.17

func Handle(ctx context.Context, rp interface{})

Handle logs the given error and reports it to sentry.

func HandleError

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

HandleError reports the passed error to sentry

func HandleErrorNoStack added in v0.1.29

func HandleErrorNoStack(ctx context.Context, err error)

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

Directories

Path Synopsis
Package raven implements a client for the Sentry error logging service.
Package raven implements a client for the Sentry error logging service.

Jump to

Keyboard shortcuts

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