[XQuery] Error Handling ?

This is a badly lacking feature in XQuery:
AFAIK, there is no way to recover/catch a dynamic error after it happens.

Actually, at least two kinds of dynamic errors should be distinguished:
fatal / non-fatal, or non-recoverable / recoverable
(XSLT2 has this distinction).

Clearly there is a semantic difference between:
1)  a wrong regular expression: this is a programming error,
      there is no real point to recover it
2) trying to parse a document is an environment-dependent
    operation, that may fail for unpredictable reasons:
  there isdefinitely a need to recover such an error

Two possible solutions:

1) introduce an error catching mechanism
     -- in my implementation (Qizx/open) I have simply added a 
catch-error() function.
    But a more sophisticated mechanism (try/catch) would probably be better.

2) at the very least, consider modifying some functions like doc()
  so that they return a conventional value (eg the empty sequence)
  instead of raising an error

Received on Saturday, 31 January 2004 18:08:09 UTC