Documentation ¶
Index ¶
- func CatchPanicAndLogError(log logg.Logg, logMsg string)
- func CatchPanicAndLogWarning(log logg.Logg, logMsg string)
- func CatchPanicDo(doFunc DoWithErrFunc)
- func CatchPanicSetErr(err *error, message string)
- func CatchPanicValueDo(panicHandle DoWithPanicFunc)
- func Cause(err error) error
- func ErrLog(log logg.Logg, err error) logg.Logg
- func Errorf(format string, args ...interface{}) error
- func Errorv(message string, arg0 interface{}, args ...interface{}) error
- func LogErrorThenDie(log logg.Logg, err error)
- func New(message string) error
- func StackTrace(err error) errorsOrig.StackTrace
- func StackTraceString(err error) string
- func WasCausedBy(err, matchErr error) bool
- func WithMessage(err error, message string) error
- func WithMessagef(err error, format string, args ...interface{}) error
- func WithMessagev(err error, message string, arg0 interface{}, args ...interface{}) error
- func WithStack(err error) error
- func WithStacktrace(log logg.Logg, err error) logg.Logg
- func Wrap(err error, message string) error
- func Wrapf(err error, message string, args ...interface{}) error
- func Wrapv(err error, message string, arg0 interface{}, args ...interface{}) error
- type DoWithErrFunc
- type DoWithLogAndMessageFunc
- type DoWithLogFunc
- type DoWithPanicFunc
- type PanicError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CatchPanicAndLogError ¶
Catch panic and log it
Usage:
func main() { defer errors.CatchPanicAndLogIt(log) panic("this was inevitable") // logged: "panic caught: this was inevitable" }
func CatchPanicAndLogWarning ¶
func CatchPanicDo ¶
func CatchPanicDo(doFunc DoWithErrFunc)
Catch panic, convert it to an error object, and do something with it
Usage:
func main() { defer errors.CatchPanicDo(func(err error) { fmt.Print(err.Error()) // "panic caught: this was inevitable" }) panic("this was inevitable") }
func CatchPanicSetErr ¶
Catch panic, convert it to an error object, and set an error pointer with it with a message
Usage
func do() (err error) { defer errors.CatchPanicSetErr(&err, "something happened") panic("this was inevitable") }
func main() { if err := do(); err != nil { fmt.Print(err.Error()) // "something happened: panic caught: this was inevitable" } }
func CatchPanicValueDo ¶
func CatchPanicValueDo(panicHandle DoWithPanicFunc)
Catch panic and do something with it
Usage:
func main() { defer errors.CatchPanicValueDo(func(recovered interface{}) { fmt.Print(recovered) // "this was inevitable" }) panic("this was inevitable") }
func LogErrorThenDie ¶
Log error and return logger object
func StackTrace ¶
func StackTrace(err error) errorsOrig.StackTrace
func WasCausedBy ¶
func WithMessagev ¶
Like Errorv(), but for WithMessage()
Types ¶
type DoWithErrFunc ¶
type DoWithErrFunc func(err error)
type DoWithLogAndMessageFunc ¶
type DoWithLogFunc ¶
type DoWithPanicFunc ¶
type DoWithPanicFunc func(recovered interface{})
type PanicError ¶
type PanicError struct {
// contains filtered or unexported fields
}
func NewPanicError ¶
func NewPanicError(recovered interface{}) (result PanicError)
func (PanicError) Error ¶
func (pe PanicError) Error() string
Click to show internal directories.
Click to hide internal directories.