Skip to content

Instantly share code, notes, and snippets.

@yrashk
Created May 21, 2014 04:31
Show Gist options
  • Save yrashk/3c1257e864daa13f38a3 to your computer and use it in GitHub Desktop.
Save yrashk/3c1257e864daa13f38a3 to your computer and use it in GitHub Desktop.
func TestErr(t *testing.T) {
passed := false
handled := false
err.Handle("this kind of failure", func(e error) {
handled = true
}).
Handle("that kind of failure", func(e error) {
}).
Run(func(h err.H) {
v := h(err.Ignore)(exampleFunction())
assert.Equal(t, v, 1)
passed = true
h("this kind of failure")(exampleFunction())
passed = false
})
assert.True(t, passed)
assert.True(t, handled)
}
func exampleFunction() (int, error) {
return 1, errors.New("some error")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment