11 November 2020 05:31 PM
The try/catch expression allows you to catch and handle exceptions in your XQuery code. Most exceptions can be caught with a try/catch block, but some exceptions are not. This article describes scenarios where exceptions are not caught.
The following exceptions are not caught by a try/catch block.
Differences between XDMP-CANCELED and SVC-CANCELED:
There is really no difference between XDMP-CANCELED and SVC-CANCELED. Both these messages mean the same thing and are triggered the same way, either by an explicit cancel or implicitly by the client closing the connection while the request is still running.
This message usually indicates that an operation such as a merge, backup or query was explicitly canceled. The message includes information about what operation was canceled. Cancellation may occur through the Admin Interface or by calling an explicit cancellation function, such as xdmp:request-cancel. Also this is what the server normally does when it detects that a query has been canceled or 'abandoned' at the browser level. The server maintains a keep-alive timeout of < 2 minutes and then cancels the query and logs it in the ErrorLog.txt file (if the app-server has log-errors set to true).
Errors that happen during the commit:
The MarkLogic query evaluator looks at all the updates that were requested, and performs them together at the end of the transaction after all the XQuery statements have been evaluated – including after the try/catch expression. Errors that occur during the commit phase of an update transaction are not caught by a try/catch block.
The workaround for this limitation is to execute the updates in an
Examples of commit time errors include XDMP-RANGEINDEX.
Static errors (e.g. syntax errors):
Static (Syntax) errors are seen before the try/catch statements have been evaluated and, as a result, are not caught by the try/catch block
Some system level errors:
Some system level errors (e.g. out of memory) are handled by MarkLogic Server and not exposed to the application.
Lazily Evaluated Exceptions
MarkLogic Server is a lazy evaluator. Some exceptions are thrown only when you actually look at the result and not when the operation is requested. In these circumstances, you can force the evaluator to wait for the results to complete inside a try-catch block by using functions such as valueOf() or xdmp:eager().