errors

package
v0.4.22 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 16 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

  • ENVIRONMENT
    • Default environment of sentry reported in the dashboard
  • SENTRY_DSN
    • URL of the sentry DSN
  • 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 Hide added in v0.1.56

func Hide(ctx context.Context, err, exposedErr error) error

Hide checks whether the given error err is a context.Canceled or context.DeadlineExceeded error and if so exposes these errors as wrapped errors while maintaining the given err as string. If the optional exposedErr is provided, it is attached as prefix to the returned error. If the given err is not any of the above ones, the given exposedErr (if present) is wrapped as prefix to the returned error, if there is an err that is not nil.

func IsStdLibContextError added in v0.4.3

func IsStdLibContextError(err error) bool

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 BricksError added in v0.4.13

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

BricksError - a bricks err is a bricks specific error which provides convenience functions to be transformed into runtime.Errors (JSON errors) pb generate can be used to create a set of pre defined BricksErrors based on a JSON specification, see pb generate for details

func NewBricksError added in v0.4.13

func NewBricksError(opts ...BricksErrorOption) *BricksError

func (*BricksError) AsRuntimeError added in v0.4.13

func (e *BricksError) AsRuntimeError() *runtime.Error

AsRuntimeError - returns the BricksError as bricks runtime.Error which aligns with a JSON error object

func (*BricksError) Code added in v0.4.13

func (e *BricksError) Code() string

func (*BricksError) Detail added in v0.4.13

func (e *BricksError) Detail() string

func (*BricksError) Error added in v0.4.13

func (e *BricksError) Error() string

func (*BricksError) Status added in v0.4.13

func (e *BricksError) Status() int

func (*BricksError) Title added in v0.4.13

func (e *BricksError) Title() string

type BricksErrorOption added in v0.4.13

type BricksErrorOption func(e *BricksError)

func WithCode added in v0.4.13

func WithCode(s string) BricksErrorOption

func WithDetail added in v0.4.13

func WithDetail(s string) BricksErrorOption

func WithStatus added in v0.4.13

func WithStatus(s int) BricksErrorOption

func WithTitle added in v0.4.13

func WithTitle(s string) BricksErrorOption

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