aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgutmet <me.git@gutmet.org>2020-04-27 20:09:58 +0200
committergutmet <me.git@gutmet.org>2020-04-27 20:09:58 +0200
commita611f9fd7cd971ab4ebf04e3fa76377af442e992 (patch)
tree42a5037e24d85f1e28ced03123b6d9f92dafa89c
parent0e21baa45c8befaa6e10ced04a9b8d43ef5c26c9 (diff)
downloadlaymanshex-a611f9fd7cd971ab4ebf04e3fa76377af442e992.tar.gz
better error message for byte field of unknown size
-rw-r--r--laymanshex.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/laymanshex.go b/laymanshex.go
index 84d71c6..21d1f88 100644
--- a/laymanshex.go
+++ b/laymanshex.go
@@ -16,7 +16,11 @@ import (
func optPanic(msg string, err error) {
if err != nil {
- panic(errors.New(msg + ": " + err.Error()))
+ if msg != "" {
+ panic(msg + ": " + err.Error())
+ } else {
+ panic(err)
+ }
}
}
@@ -174,7 +178,11 @@ func (part *filePart) setByteFieldHandling(assignments map[string]*formatAssignm
ass.used = true
err = nil
} else {
- err = errors.New("Could neither parse size to int64 nor obtain value from -fvar")
+ msg := "byte field: could neither parse size to int64 nor obtain value from -fvar"
+ if part.name != "" {
+ msg += " definition " + part.name
+ }
+ err = errors.New(msg)
}
}
optPanic(part.name, err)