User's Guide

Handling Exceptions

The following sections document how to handle parse and DOM exceptions.

Handling Parse Exceptions

If the XML parser detects errors while parsing an XML stream, the errors are reported by signaling exceptions. The exception class SgmlException is used to report errors. Exceptions will cause termination of the parse process unless they are handled by the application.

The following example shows an XML parser exception handler that writes error information to the Transcript. After an error is handled, the parser attempts to continue parsing.

[ AbtXmlDOMParser newValidatingParser parseURI: 'bogus.xml' ]
    when: SgmlExceptions::SgmlException
    do: [ :aSignal | 
        Transcript cr; show: aSignal argument printString ].

Handling DOM Exceptions

Exceptions that occur while manipulating the DOM are reported using the exception class AbtDOMException.

"An exception is reported for the case below because of a mismatch in the 
'ownerDocument' property for the two elements."
[ ( AbtDOMDocument new createElement: 'test' )
  appendChild: AbtDOMElement new ]
  when: AbtDOMConstants::AbtDOMException
    do: [ :aSignal | 
      Transcript cr; show: aSignal argument printString ].
 


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]