Documentation
¶
Overview ¶
Package errhandler provide utility to adding error handling.
With is the function to handle the error, this function must be called with defer.
for example:
import (
"github.com/payfazz/go-errors"
"github.com/payfazz/go-errors/errhandler"
)
func main() {
defer errhandler.With(nil)
something, err := getSomething()
errhandler.Check(errors.Wrap(err)) // using Wrap so we got the stack trace
something2, err := getSomething2(something)
if err != nil {
errhandler.Check(errors.NewWithCause("getSomething2 is failing", err))
}
}
NOTE ¶
please note that With adding some overhead, do not use it frequently, you should use golang idiom:
if err != nil {
return errors.Wrap(err)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CatchAndSet ¶
CatchAndSet create function to catch error and set it to err
func UnwrapUnhandledError ¶
UnwrapUnhandledError will unwrap the wrapper error used by errhandler.With to the original error
This may be needed if you want to doing recover() manualy in the defer
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.