errorreport

package
v0.61.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAndReportPanic

func CheckAndReportPanic()

CheckAndReportPanic checks current function is not raising an error with panic and it reports the error when recover returns an error. This function be called with defer to catch the error happend in the function.

Types

type CloudErrorReportWriter

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

CloudErrorReportWriter sends error over Cloud Error Reporting on GCP.

func NewCloudErrorReportWriter

func NewCloudErrorReportWriter(projectId string, apiKey string) (*CloudErrorReportWriter, error)

NewCloudErrorReportWriter returns a new instance of CloudErrorReporter.

func (*CloudErrorReportWriter) WriteReportSync

func (c *CloudErrorReportWriter) WriteReportSync(ctx context.Context, err error)

WriteReportSync implements Reporter.

type ConsoleReportWriter

type ConsoleReportWriter struct {
}

ConsoleReportWriter reports error through stderr.

func (*ConsoleReportWriter) WriteReportSync

func (r *ConsoleReportWriter) WriteReportSync(ctx context.Context, err error)

type ReportWriter

type ReportWriter interface {
	// WriteReportSync reports the given error.
	WriteReportSync(ctx context.Context, err error)
}

ReportWriter is an interface to send an error. The destination can be only stdout or a backend for collecting errors.

type Reporter

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

Reporter is an interface to record the error.

var DefaultErrorReporter *Reporter = &Reporter{
	metadata: map[string]string{},
	writer:   &ConsoleReportWriter{},
}

DefaultErrorReporter is the default reporter to be used for reporting an error on panic.

func NewReporter

func NewReporter(reportWriter ReportWriter) *Reporter

NewReporter returns a new Reporter with the given ReportWriter.

func (*Reporter) GetMetadata

func (r *Reporter) GetMetadata() map[string]string

func (*Reporter) ReportSync

func (r *Reporter) ReportSync(ctx context.Context, err error)

ReportSync reports the error using the report writer.

func (*Reporter) SetMetadataEntry

func (r *Reporter) SetMetadataEntry(key string, value string)

Jump to

Keyboard shortcuts

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