couchbaselabs / gojsonsm

Go implementation of my JSONSM algorithm.
9 stars 7 forks source link

reword error for "runtime error: index out of range" #116

Closed nelio2k closed 5 years ago

nelio2k commented 5 years ago

When a weird filter gets entered, like: (int>equals10000) AND (int<>1000000) OR (float IS NOT NULL)

gojsonsm will be looking for "equals10000" in the doc. If it's not found, it returns an error "runtime error: index out of range"

It'd be nice to check for this condition and return something prettier as this message may cause mass hysteria when customers or support sees it.

brett19 commented 5 years ago

This is a bit of a strange parser error isn't it? Shouldn't equals10000 end up being an unexpected identifier rather than an arbitrary string?

nelio2k commented 5 years ago

I think "equals10000" fits an identifying rule, though. It's alpha-numeric and doesn't start with a number. There shouldn't be a limitation of naming convention.

nelio2k commented 5 years ago

Just re-read your comment. For equals10000 to be an arbitrary string, it needs to be enclosed in quotes. ( int > "equals10000" ) whereas without quotes as shown, it is assumed to be a field in a doc