Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CrashReport ¶
type CrashReport struct { Timestamp time.Time `json:"timestamp"` Error string `json:"error"` Stack string `json:"stack"` SystemInfo SystemInfo `json:"system_info,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` }
CrashReport represents a single crash report
type ErrorHandler ¶
ErrorHandler is a function type for custom error handling
type Options ¶ added in v1.0.0
type Options struct { // ErrorHandler is a custom error handling function ErrorHandler ErrorHandler // DumpToFile enables dumping errors to a file DumpToFile bool // FilePath is the path to the file to dump errors to FilePath string // ExitOnPanic enables exiting the program after handling a panic ExitOnPanic bool // IncludeSystemInfo enables including system information in crash reports IncludeSystemInfo bool // Metadata is custom metadata to include in crash reports Metadata map[string]string // WipeFile enables wiping the crash file on initialization WipeFile bool }
Options struct holds the configuration for panic handling
type PanicHandler ¶
type PanicHandler struct {
// contains filtered or unexported fields
}
func New ¶
func New(options Options) *PanicHandler
New initializes a new PanicHandler with optional configurations
func (*PanicHandler) GetLastNCrashReports ¶
func (ph *PanicHandler) GetLastNCrashReports(n int) ([]CrashReport, error)
GetLastNCrashReports retrieves the last N crash reports from the log file
func (*PanicHandler) Recover ¶
func (ph *PanicHandler) Recover()
Recover is the main function to recover from panics
func (*PanicHandler) SafeGo ¶
func (ph *PanicHandler) SafeGo(f func())
SafeGo wraps a function to be executed in a goroutine with panic recovery
func (*PanicHandler) WipeCrashFile ¶
func (ph *PanicHandler) WipeCrashFile() error
WipeCrashFile clears all crash reports from the log file
type SystemInfo ¶
type SystemInfo struct { OS string `json:"os"` Architecture string `json:"architecture"` GoVersion string `json:"go_version"` }
SystemInfo represents system information
Click to show internal directories.
Click to hide internal directories.