better error message for byte field of unknown size

This commit is contained in:
gutmet 2020-04-27 20:09:58 +02:00
parent 0e21baa45c
commit a611f9fd7c

View File

@ -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)