errors

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

errors implements an errors/crashes reporter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DSN represents the Sentry DSN.
	DSN string `yaml:"dsn"`

	// Wait represents a flag indicating if the calls to Sentry should be done synchronously
	// (effectively blocking the caller).
	Wait bool `yaml:"wait"`

	// Debug represents a flags indicating whether to enable internal reporter activity logging.
	// This is mainly for debug purposes.
	Debug bool `yaml:"debug"`
}

Config represents an errors reporter configuration.

type Reporter

type Reporter struct {
	*debug.D
	// contains filtered or unexported fields
}

Reporter represents an errors reporter instance.

func New

func New(config *Config) (*Reporter, error)

New returns a new errors reporter instance.

func (*Reporter) LogHandler

func (r *Reporter) LogHandler() log15.Handler

LogHandler is a log15.Handler that sends an event to Sentry if an error-level record message is logged.

func (*Reporter) PanicHandler

func (r *Reporter) PanicHandler(fn func(interface{}))

PanicHandler is a function that recovers from a panic and sends an event to Sentry. If a fn function is provided it will be executed with the recovered panic value as parameter before returning – typically to exit the program with a non-nil return code. This handler should be used with a defer statement at the beginning of the program to watch for.

func (*Reporter) SendError

func (r *Reporter) SendError(err error, tags map[string]string)

SendError sends the specified error to Sentry. If tags is not nil, they will be added to the event.

func (*Reporter) SetSentryTransport

func (r *Reporter) SetSentryTransport(t sentry.Transport)

SetSentryTransport sets the errors reporter's Sentry client transport. This is mainly for testing purposes.

func (*Reporter) Start

func (r *Reporter) Start(_ context.Context) error

Start is a no-op operation.

func (*Reporter) Stop

func (r *Reporter) Stop(_ context.Context) error

Stop is a no-op operation.

type SentryTestTransport

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

SentryTestTransport is an implementation of the sentry.Transport interface for testing purposes.

func (*SentryTestTransport) Configure

func (t *SentryTestTransport) Configure(_ sentry.ClientOptions)

Configure is a no-op for SentryTestTransport.

func (*SentryTestTransport) Events

func (t *SentryTestTransport) Events() []*sentry.Event

Events returns a list of events received by the Transport.

func (*SentryTestTransport) Flush

func (t *SentryTestTransport) Flush(_ time.Duration) bool

Flush is a no-op for SentryTestTransport. It always returns true immediately.

func (*SentryTestTransport) SendEvent

func (t *SentryTestTransport) SendEvent(event *sentry.Event)

SendEvent assembles a new packet out of `Event` and sends it to remote server.

Jump to

Keyboard shortcuts

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