summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-11-30 21:21:39 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2017-11-30 21:21:39 -0500
commite63e838d85eed5147aefcbca81ce18a16cd8fd4b (patch)
tree14693a936f8931fe5b8531b9391a035366204faa
parente3b3c08e62f07c75426536c3407dfebc4b71405a (diff)
ez: get a little more robust
-rw-r--r--ez.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/ez.go b/ez.go
index eca3494..8fe429d 100644
--- a/ez.go
+++ b/ez.go
@@ -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 {