From 6ba6218ae439ac3f420b8d077fc9ba572eb4def9 Mon Sep 17 00:00:00 2001 From: Shaquille Wyan Que Date: Wed, 15 May 2019 11:22:04 -0500 Subject: [PATCH] changed out of range error message name and fixed formatting --- pql/ast.go | 2 +- pql/parser.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pql/ast.go b/pql/ast.go index e14a93fe1..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(fmt.Sprintf("out of bounds: %s", 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 8c3b608c9..cef8a9b9b 100644 --- a/pql/parser.go +++ b/pql/parser.go @@ -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)