diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-11-30 21:21:39 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-11-30 21:21:39 -0500 |
commit | e63e838d85eed5147aefcbca81ce18a16cd8fd4b (patch) | |
tree | 14693a936f8931fe5b8531b9391a035366204faa | |
parent | e3b3c08e62f07c75426536c3407dfebc4b71405a (diff) |
ez: get a little more robust
-rw-r--r-- | ez.go | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -2,6 +2,8 @@ package libfastimport import ( "strconv" + + "github.com/pkg/errors" ) type ezfiw struct { @@ -32,12 +34,18 @@ type ezfir struct { err error } +var ezPanic = errors.New("everything is fine") + func (e *ezfir) Defer() error { - if r := recover(); r != nil { - if e.err != nil { - return e.err + if e.err != nil { + r := recover() + if r == nil { + panic("ezfir.err got set, but didn't panic") + } + if r != ezPanic { + panic(r) } - panic(r) + return e.err } return nil } @@ -47,7 +55,7 @@ func (e *ezfir) Errcheck(err error) { return } e.err = err - panic("everything is fine") + panic(ezPanic) } func (e *ezfir) PeekLine() string { |