crash

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2018 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewcapturerCaptureInvocation

func NewcapturerCaptureInvocation(ident1 *raven.Packet, ident2 map[string]string, ident3 string, ident4 chan error) *capturerCaptureInvocation

NewcapturerCaptureInvocation creates a new instance of capturerCaptureInvocation

Types

type Fakecapturer

type Fakecapturer struct {
	CaptureHook func(*raven.Packet, map[string]string) (string, chan error)
	CloseHook   func()

	CaptureCalls []*capturerCaptureInvocation
	CloseCalls   []*capturerCloseInvocation
}

Fakecapturer is a mock implementation of capturer for testing. Use it in your tests as in this example:

package example

func TestWithcapturer(t *testing.T) {
	f := &crash.Fakecapturer{
		CaptureHook: func(ident1 *raven.Packet, ident2 map[string]string) (ident3 string, ident4 chan error) {
			// ensure parameters meet expections, signal errors using t, etc
			return
		},
	}

	// test code goes here ...

	// assert state of FakeCapture ...
	f.AssertCaptureCalledOnce(t)
}

Create anonymous function implementations for only those interface methods that should be called in the code under test. This will force a panic if any unexpected calls are made to FakeCapture.

func NewFakecapturerDefaultError

func NewFakecapturerDefaultError(t capturerTestingT) *Fakecapturer

NewFakecapturerDefaultError returns an instance of Fakecapturer with all hooks configured to call t.Error

func NewFakecapturerDefaultFatal

func NewFakecapturerDefaultFatal(t capturerTestingT) *Fakecapturer

NewFakecapturerDefaultFatal returns an instance of Fakecapturer with all hooks configured to call t.Fatal

func NewFakecapturerDefaultPanic

func NewFakecapturerDefaultPanic() *Fakecapturer

NewFakecapturerDefaultPanic returns an instance of Fakecapturer with all hooks configured to panic

func (*Fakecapturer) AssertCaptureCalled

func (f *Fakecapturer) AssertCaptureCalled(t capturerTestingT)

AssertCaptureCalled calls t.Error if Fakecapturer.Capture was not called

func (*Fakecapturer) AssertCaptureCalledN

func (f *Fakecapturer) AssertCaptureCalledN(t capturerTestingT, n int)

AssertCaptureCalledN calls t.Error if Fakecapturer.Capture was called less than n times

func (*Fakecapturer) AssertCaptureCalledOnce

func (f *Fakecapturer) AssertCaptureCalledOnce(t capturerTestingT)

AssertCaptureCalledOnce calls t.Error if Fakecapturer.Capture was not called exactly once

func (*Fakecapturer) AssertCaptureCalledOnceWith

func (_f9 *Fakecapturer) AssertCaptureCalledOnceWith(t capturerTestingT, ident1 *raven.Packet, ident2 map[string]string)

AssertCaptureCalledOnceWith calls t.Error if Fakecapturer.Capture was not called exactly once with the given values

func (*Fakecapturer) AssertCaptureCalledWith

func (_f7 *Fakecapturer) AssertCaptureCalledWith(t capturerTestingT, ident1 *raven.Packet, ident2 map[string]string)

AssertCaptureCalledWith calls t.Error if Fakecapturer.Capture was not called with the given values

func (*Fakecapturer) AssertCaptureNotCalled

func (f *Fakecapturer) AssertCaptureNotCalled(t capturerTestingT)

AssertCaptureNotCalled calls t.Error if Fakecapturer.Capture was called

func (*Fakecapturer) AssertCloseCalled

func (f *Fakecapturer) AssertCloseCalled(t capturerTestingT)

AssertCloseCalled calls t.Error if Fakecapturer.Close was not called

func (*Fakecapturer) AssertCloseCalledN

func (f *Fakecapturer) AssertCloseCalledN(t capturerTestingT, n int)

AssertCloseCalledN calls t.Error if Fakecapturer.Close was called less than n times

func (*Fakecapturer) AssertCloseCalledOnce

func (f *Fakecapturer) AssertCloseCalledOnce(t capturerTestingT)

AssertCloseCalledOnce calls t.Error if Fakecapturer.Close was not called exactly once

func (*Fakecapturer) AssertCloseNotCalled

func (f *Fakecapturer) AssertCloseNotCalled(t capturerTestingT)

AssertCloseNotCalled calls t.Error if Fakecapturer.Close was called

func (*Fakecapturer) Capture

func (_f1 *Fakecapturer) Capture(ident1 *raven.Packet, ident2 map[string]string) (ident3 string, ident4 chan error)

func (*Fakecapturer) CaptureCalled

func (f *Fakecapturer) CaptureCalled() bool

CaptureCalled returns true if Fakecapturer.Capture was called

func (*Fakecapturer) CaptureCalledN

func (f *Fakecapturer) CaptureCalledN(n int) bool

CaptureCalledN returns true if Fakecapturer.Capture was called at least n times

func (*Fakecapturer) CaptureCalledOnce

func (f *Fakecapturer) CaptureCalledOnce() bool

CaptureCalledOnce returns true if Fakecapturer.Capture was called exactly once

func (*Fakecapturer) CaptureCalledOnceWith

func (_f8 *Fakecapturer) CaptureCalledOnceWith(ident1 *raven.Packet, ident2 map[string]string) bool

CaptureCalledOnceWith returns true if Fakecapturer.Capture was called exactly once with the given values

func (*Fakecapturer) CaptureCalledWith

func (_f6 *Fakecapturer) CaptureCalledWith(ident1 *raven.Packet, ident2 map[string]string) (found bool)

CaptureCalledWith returns true if Fakecapturer.Capture was called with the given values

func (*Fakecapturer) CaptureNotCalled

func (f *Fakecapturer) CaptureNotCalled() bool

CaptureNotCalled returns true if Fakecapturer.Capture was not called

func (*Fakecapturer) CaptureResultsForCall

func (_f10 *Fakecapturer) CaptureResultsForCall(ident1 *raven.Packet, ident2 map[string]string) (ident3 string, ident4 chan error, found bool)

CaptureResultsForCall returns the result values for the first call to Fakecapturer.Capture with the given values

func (*Fakecapturer) Close

func (_f11 *Fakecapturer) Close()

func (*Fakecapturer) CloseCalled

func (f *Fakecapturer) CloseCalled() bool

CloseCalled returns true if Fakecapturer.Close was called

func (*Fakecapturer) CloseCalledN

func (f *Fakecapturer) CloseCalledN(n int) bool

CloseCalledN returns true if Fakecapturer.Close was called at least n times

func (*Fakecapturer) CloseCalledOnce

func (f *Fakecapturer) CloseCalledOnce() bool

CloseCalledOnce returns true if Fakecapturer.Close was called exactly once

func (*Fakecapturer) CloseNotCalled

func (f *Fakecapturer) CloseNotCalled() bool

CloseNotCalled returns true if Fakecapturer.Close was not called

func (*Fakecapturer) Reset

func (f *Fakecapturer) Reset()

func (*Fakecapturer) SetCaptureInvocation

func (_f3 *Fakecapturer) SetCaptureInvocation(calls_f4 []*capturerCaptureInvocation, fallback_f5 func() (string, chan error))

SetCaptureInvocation configures capturer.Capture to return the given results when called with the given parameters If no match is found for an invocation the result(s) of the fallback function are returned

func (*Fakecapturer) SetCaptureStub

func (_f2 *Fakecapturer) SetCaptureStub(ident3 string, ident4 chan error)

SetCaptureStub configures capturer.Capture to always return the given values

type Reporter

type Reporter interface {
	Report(context.Context, *httpx.Request, merry.Error)
	Close() merry.Error
}

Reporter sends a crash report to an external service

type SentryReporter

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

SentryReporter reports errors to an external Sentry service

func NewSentryReporter

func NewSentryReporter(dsn string) (*SentryReporter, merry.Error)

NewSentryReporter instantiates a *raven.Client and *SentryReporter from a sentry DSN string

func (*SentryReporter) Close

func (s *SentryReporter) Close() (exception merry.Error)

Close safely closes the *raven.Client

func (*SentryReporter) Report

func (s *SentryReporter) Report(ctx context.Context, r *httpx.Request, err merry.Error)

Report checks if the provided merry.Error is a panic (as defined by errors.IsPanic), and if so, constructs a stacktrace and sends an an exception to sentry

Jump to

Keyboard shortcuts

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