This is a bit an off-the-wall request but I figured it doesn't hurt to throw out here as an idea.
When I have an error in my query I typically get a BaseXException saying something like:
org.basex.core.BaseXException: Stopped at line 42, column 55: [XPST0003] Expecting ")", found """.
However, it doesn't show me the query. Since I generate (sometimes large) queries automatically, this message by itself is not always very helpful (to put it very mildly). Either I print all my queries in their entirety, something that results in a dazzling amount of output. Or I jump through some hoops and try to keep my last query so it can be printed alongside the exception. Both are not very satisfactory solutions.
I was thinking though how nice it would be if the exception could print the query for me. And the icing on the cake would be if (in the above example) it would print an extra line just after line 42 with 54 spaces and ^ at column 55, so I get an arrow pointing out where the error is without me having to count to 42 first and then to 55.
Whatcha all think?
Personally, I think it's such a good idea I was thinking of doing it myself. If the BaseX6.3 source were available, that is.
Mark Boon
Hi Mark I would be a bit concerned about printing entire XQuery as I use it often over Internet and including possibly large XQuery text the message could be dangerous. In your code, you have probably the xquery just one or two lines above the place, the code have thrown the exception. You may let your catch code to print the XQuery on your own, without forcing BaseX to do it for you.
Printing thee lines of XQuery would be perfectly fine.
Just my point of view.
Jan
On Thu, Dec 9, 2010 at 4:15 AM, Mark Boon mboon@avatar-reality.com wrote:
This is a bit an off-the-wall request but I figured it doesn't hurt to throw out here as an idea.
When I have an error in my query I typically get a BaseXException saying something like:
org.basex.core.BaseXException: Stopped at line 42, column 55: [XPST0003] Expecting ")", found """.
However, it doesn't show me the query. Since I generate (sometimes large) queries automatically, this message by itself is not always very helpful (to put it very mildly). Either I print all my queries in their entirety, something that results in a dazzling amount of output. Or I jump through some hoops and try to keep my last query so it can be printed alongside the exception. Both are not very satisfactory solutions.
I was thinking though how nice it would be if the exception could print the query for me. And the icing on the cake would be if (in the above example) it would print an extra line just after line 42 with 54 spaces and ^ at column 55, so I get an arrow pointing out where the error is without me having to count to 42 first and then to 55.
Whatcha all think?
Personally, I think it's such a good idea I was thinking of doing it myself. If the BaseX6.3 source were available, that is.
Mark Boon _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
org.basex.core.BaseXException: Stopped at line 42, column 55: [XPST0003] Expecting ")", found """.
However, it doesn't show me the query. Since I generate (sometimes large) queries automatically, this message by itself is not always very helpful (to put it very mildly).
In your case, I'd recommend to wrap query execution with try/catch and lookup the relevant snippet by yourself; this is similar to what Jan has already proposed. If this should not be possible for reason, feel free to comment back on this.
Based on my experiences, a more detailed error feedback would represent undesirable overhead.
Christian
basex-talk@mailman.uni-konstanz.de