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 (*Reporter) ReportSync ¶
ReportSync reports the error using the report writer.