changed out of range error message name and fixed formatting

This commit is contained in:
Shaquille Wyan Que 2019-05-15 11:22:04 -05:00
parent b770167db6
commit 6ba6218ae4
2 changed files with 4 additions and 3 deletions

View file

@ -160,7 +160,7 @@ func (q *Query) addNumVal(val string) {
ival, err = strconv.ParseInt(val, 10, 64)
}
if err != nil {
panic(fmt.Sprintf("out of bounds: %s", err))
panic(fmt.Sprintf("%s: %s", intOutOfRangeError, err))
}
if elem.inList {
if elem.lastCond != ILLEGAL {

View file

@ -28,7 +28,7 @@ const timeFormat = "2006-01-02T15:04"
// error strings in the parser
const duplicateArgErrorMessage = "duplicate argument provided"
const outOfBoundsErrorMessage = "out of bounds"
const intOutOfRangeError = "integer is not in signed 64-bit range"
// parser represents a parser for the PQL language.
type parser struct {
@ -72,7 +72,8 @@ func (p *parser) Parse() (*Query, error) {
p.Execute()
}()
if v != nil {
if strings.HasPrefix(v.(string), duplicateArgErrorMessage) || strings.HasPrefix(v.(string), outOfBoundsErrorMessage) {
errorMessage := v.(string)
if strings.HasPrefix(errorMessage, duplicateArgErrorMessage) || strings.HasPrefix(errorMessage, intOutOfRangeError) {
return nil, fmt.Errorf("%s", v)
} else {
panic(v)