Documentation ¶
Index ¶
- Constants
- func AsJSON(e EnhancedError, verbosityThreshold ...int) json.RawMessage
- func JSONStackTraceFormatter(st pkgerrors.StackTrace) string
- func LogFMTFormatter(e EnhancedError, verbosityThreshold int, ...) string
- func MultilineFormatter(e EnhancedError, verbosityThreshold int, ...) string
- func MultilineStackTraceFormatter(st pkgerrors.StackTrace) string
- func NoStackTrace(stackTrace errors.StackTrace) string
- type EnhancedError
- type ErrorFormatter
- type ErrorOpt
- type ErrorOptType
- type ErrorsManager
- type JSONFormatter
- type LogName
- type LoggerFunc
- type LoggerOption
- type StackTraceFormatter
- type Wrapper
- type Writer
Constants ¶
View Source
const ( LogDebug = iota + 10 LogInfo LogWarning LogError )
Variables ¶
This section is empty.
Functions ¶
func AsJSON ¶
func AsJSON(e EnhancedError, verbosityThreshold ...int) json.RawMessage
func JSONStackTraceFormatter ¶
func JSONStackTraceFormatter(st pkgerrors.StackTrace) string
func LogFMTFormatter ¶
func LogFMTFormatter(e EnhancedError, verbosityThreshold int, stackTraceFormatter StackTraceFormatter) string
func MultilineFormatter ¶
func MultilineFormatter(e EnhancedError, verbosityThreshold int, stackTraceFormatter StackTraceFormatter) string
func MultilineStackTraceFormatter ¶
func MultilineStackTraceFormatter(st pkgerrors.StackTrace) string
func NoStackTrace ¶
func NoStackTrace(stackTrace errors.StackTrace) string
Types ¶
type EnhancedError ¶
type EnhancedError interface { error // With adds an option to the error. If the option already exists (by checking its type), it will be overwritten. With(opts ...ErrorOpt) EnhancedError // From returns a enhanced error from common one. If the error is already enhanced, it will be returned as copy of previous one. From(err error) EnhancedError // FromEmpty returns a new enhanced error from nothing. It is used with Template() function to mark proper stack trace. FromEmpty() EnhancedError // Log logs the error using the default logger or the loggers specified in the function. Loggers must be registered before either the program will panic. Log(loggers ...LogName) // Is checks if the error is of the same type as the one specified. It will check the template ID and the error ID if comparing enhanced errors. Is(err error) bool // Wrap wraps the error with a message. Is is used as a shortcut for With(Wrapper(msg)) Wrap(msg string) EnhancedError // GetStackTrace returns the stack trace of the error. GetStackTrace() errors.StackTrace // GetStackTraceHash returns the hash of the stack trace of the error. GetStackTraceHash() string // GetInternalError returns the internal error. GetInternalError() error // GetOpts returns the options of the error. GetOpts() map[ErrorOptType]ErrorOpt // GetOpt sets error opt value GetOpt(opt ErrorOpt) bool // GetErrorID returns the error ID of the error. GetErrorID() string }
func Enhance ¶
func Enhance(err error) EnhancedError
func New ¶
func New(msg string) EnhancedError
func Newf ¶
func Newf(msg string, data ...interface{}) EnhancedError
func Template ¶
func Template() EnhancedError
func Wrap ¶
func Wrap(err error, msg string) EnhancedError
func Wrapf ¶
func Wrapf(err error, msg string, data ...interface{}) EnhancedError
type ErrorFormatter ¶
type ErrorFormatter func(e EnhancedError, verbosityThreshold int, stackTraceFormatter StackTraceFormatter) string
type ErrorOpt ¶
type ErrorOpt interface { // Type returns the type of the option. It must be unique withing single enhanced error. If not, the last option will be used. Type() ErrorOptType // MapFormatter returns a map that will be used to format the error. The map will be merged with the map returned by the error. MapFormatter() map[string]interface{} // Verbosity returns the verbosity of the option. The higher the value, the more specific the option is. The default value is 0. Verbosity() int }
type ErrorOptType ¶
type ErrorOptType string
type ErrorsManager ¶
type ErrorsManager interface { // SaveStack saves the stack trace of the error in the stack trace file. Format is optional and can be used to format the stack trace SaveStack(err EnhancedError, format ...StackTraceFormatter) error // RegisterLogger registers a logger for a specific log name RegisterLogger(name LogName, logger LoggerFunc) // SetDefaultLogger sets the default logger SetDefaultLogger(logger LoggerFunc) // Setup creates a new stack trace file and reads the existing one Setup(stackTracePath string) error }
func Manager ¶
func Manager() ErrorsManager
type JSONFormatter ¶
type JSONFormatter func(e EnhancedError, verbosityThreshold int) json.RawMessage
type LoggerFunc ¶
type LoggerFunc func(err EnhancedError)
func CustomLogger ¶
func CustomLogger(opts ...LoggerOption) LoggerFunc
func DefaultLogger ¶
func DefaultLogger() LoggerFunc
type LoggerOption ¶
type LoggerOption func(*loggerOpts)
func WithErrorFormatter ¶
func WithErrorFormatter(formatter ErrorFormatter) LoggerOption
func WithSaveStack ¶
func WithSaveStack(saveStack bool) LoggerOption
func WithStackTraceFormatter ¶
func WithStackTraceFormatter(formatter StackTraceFormatter) LoggerOption
func WithVerbosity ¶
func WithVerbosity(verbosity int) LoggerOption
type StackTraceFormatter ¶
type StackTraceFormatter func(errors.StackTrace) string
type Wrapper ¶
type Wrapper string
func (Wrapper) MapFormatter ¶
func (Wrapper) Type ¶
func (Wrapper) Type() ErrorOptType
Source Files ¶
Click to show internal directories.
Click to hide internal directories.