Using an Error Handler

dscape edited this page Mar 3, 2011 · 4 revisions

Using an Error Handler

A centralized error handler can also be used removing the need for a try catch statement in each XQuery main module and allowing you to control exception handling consistently.

If you have set an error handler you can configure rewrite to use it by adding:

 <routes useErrorHandler="Yes">

And the error handler error.xqy:

 xquery version "1.0-ml";

 import module namespace h = "helper.xqy" at "/lib/helper.xqy";
 declare variable $error:errors as node()* external;

 h:error( $error:errors )

By doing so rewrite will raise the following fn:error exceptions:

  1. Redirect will raise a 301 - Moved Permantly fn:error( xs:QName( 'REWRITE-REDIRECT' ), '301', $urlToRedirectTo ). (default behavior invokes a redirect handler as described in redirect-to)