diff --git a/pql/ast.go b/pql/ast.go index 20b757946..49503474c 100644 --- a/pql/ast.go +++ b/pql/ast.go @@ -160,7 +160,7 @@ func (q *Query) addNumVal(val string) { ival, err = strconv.ParseInt(val, 10, 64) } if err != nil { - panic(err) + panic(fmt.Sprintf("%s: %s", intOutOfRangeError, err)) } if elem.inList { if elem.lastCond != ILLEGAL { diff --git a/pql/parser.go b/pql/parser.go index 6a28f560e..e733038d7 100644 --- a/pql/parser.go +++ b/pql/parser.go @@ -26,8 +26,9 @@ import ( // timeFormat is the go-style time format used to parse string dates. const timeFormat = "2006-01-02T15:04" -// duplicateArgErrorMessage is used as an error string in the parser. +// error strings in the parser const duplicateArgErrorMessage = "duplicate argument provided" +const intOutOfRangeError = "integer is not in signed 64-bit range" // parser represents a parser for the PQL language. type parser struct { @@ -71,7 +72,11 @@ func (p *parser) Parse() (*Query, error) { p.Execute() }() if v != nil { - if strings.HasPrefix(v.(string), duplicateArgErrorMessage) { + errorMessage, ok := v.(string) + if !ok { + return nil, fmt.Errorf("unexpected parser error of type %T: %[1]v", v) + } + if strings.HasPrefix(errorMessage, duplicateArgErrorMessage) || strings.HasPrefix(errorMessage, intOutOfRangeError) { return nil, fmt.Errorf("%s", v) } else { panic(v) diff --git a/pql/pqlpeg_test.go b/pql/pqlpeg_test.go index a90d58a5d..3ceff075d 100644 --- a/pql/pqlpeg_test.go +++ b/pql/pqlpeg_test.go @@ -333,6 +333,12 @@ func TestPEGErrors(t *testing.T) { { name: "RangeTimeOneStamp", input: "Row(a=4, 2010-07-04T00:00)"}, + { + name: "ArgOutOfBounds", + input: "Row(a=9223372036854775808)"}, + { + name: "ArgOutOfBoundsNeg", + input: "Row(a=-9223372036854775809)"}, } for i, test := range tests {