Is it possible to do something by using rest:forward or http:send-request? I see that rest:forward is suggested for use in situations where you have multiple XQuery updates in a row.
If a query fails, and if you cannot catch it in XQuery, you can define error-code elements in your web.xml configuration file [1]:
<error-page> <error-code>500</error-code> <location>/fatal</location> </error-page>
Maybe this helps? Christian