How to interpret error objects? #595
-
This error was thrown when attempting to format an improper query:
I am highlighting the text so the user who wrote the query can see where in the SQL their syntax error occurred. I originally assumed that the error would be in Is this expected behavior? Asking so I don't end up introducing new bugs to our application with some out of range errors in the future. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hard to reproduce without the exact code that triggers this error, but I suspect this object comes from the parser which in turn refers to the tokens created by the Tokenizer. I personally haven't seen this kind of object being thrown. Normally I would expect some instance of The Anyway, to my knowledge there's no clear start/end info inside tokens. So the best you can do is something like:
Note. It might seem to you that the actual syntax error happened earlier. But from the parser perspective the location might be different. Here I think the problem was that the parser encountered FROM token in a place where it didn't expect it. |
Beta Was this translation helpful? Give feedback.
Hard to reproduce without the exact code that triggers this error, but I suspect this object comes from the parser which in turn refers to the tokens created by the Tokenizer. I personally haven't seen this kind of object being thrown. Normally I would expect some instance of
Error
class to be thrown, not a plain object.The
token.start
property refers to the position in source text where this token starts, in this case the start of "FROM". Where thisoffset
comes from... I have no idea. Perhaps it's the offset of the current token in the array of tokens.Anyway, to my knowledge there's no clear start/end info inside tokens. So the best you can do is something like: