go-kit/herror/example_err_test.go

30 lines
428 B
Go
Raw Normal View History

package herror_test
import (
"fmt"
"dev-git.sentia.com/go/kit/herror"
)
var ErrTaskFailed = herror.New("task has failed")
func step() error {
return fmt.Errorf("cannot move")
}
func performTask() error {
if err := step(); err != nil {
return ErrTaskFailed.Wrap(err)
}
return nil
}
func Example() {
if err := performTask(); err != nil {
fmt.Print(err)
return
}
// Output: task has failed
//-> cannot move
}