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