errorreport

package
v0.0.0-...-9f7285a Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

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