Hi,
XQuery 3.0 has a convenient selective error catching mechanism. You
just use the error name (a QName) in the new catch clause, like this:
try {
...
}
catch fn:FOER0000 {
...
}
Of course, fn:FOER0000 can be any QName, so you can throw your own
error codes like this: error(xs:QName('my:error-name'), 'message'),
and let your users catch it if they want. You can even catch "error
names" like my:err1 | my:err2 to catch several codes at once, or my:*
to catch all codes in the namespace my:.
Unfortunately, it seems that all MarkLogic errors are thrown without
any specific code (which results in the default code fn:FOER0000 for
all of them), even though they all have a different code assigned
(but in a different way): XDMP-INVZIP, etc.
So for know, one has to catch all errors, inspect the value of
$err:additional, see if its /error:error/error:code is the correct
one, and if not rethrow the error.
Should not instead the MarkLogic errors be thrown using each its own
code? For instance in the namespace http://marklogic.com/xdmp/error,
already existing, by having a mapping like:
XDMP-INVZIP -> error:invzip
allowing to use:
try {
...
}
catch error:invzip {
...
}
instead of:
try {
...
}
catch fn:FOER0000 { (: catch all non-declared errors :)
if ( $err:additional/error:error/error:code eq 'XDMP-INVZIP' ) then
...
else
xdmp:rethrow()
}
Regards,
--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general