This bug affects XQuery, and it also affects XSLT if the option to treat recoverable errors as fatal is chosen (-w2 on the command line).
If doc-available() is called and returns false (meaning the document is not available), then any subsequent dynamic error occurring in the query or transformation is not reported to the ErrorListener; the only evidence that an error occurred will be that the query or transformation quits with an exception. If run from the command line this means there will be a single message saying that the query or transformation has failed, with no indication of why.
The problem occurs because the implementation of doc-available() calls the supporting code for document() after setting a temporary ErrorListener designed to suppress any error messages such as XML parsing errors while the document is being read. In situations where document() treats such errors as fatal rather than recoverable, the error listener is then not reset to its original state.
A patch is in Subversion.