Exception handling with XML classes
Errors can occur while using XML built-in classes.
For example, calling methods of a SAX handler in an invalid order raises the runtime error -8004.
By default, the program stops in case of exception. XML errors can be trapped with
the WHENEVER ERROR
or TRY/CATCH
exception handlers of
Genero. If an error occurs during a method call of an XML class, the runtime system sets
the status variable.
This code example shows the trapping of XML classes
errors.
MAIN
DEFINE w om.SaxDocumentHandler
LET w = om.SaxDocumentHandler.createFileWriter("sample.xml")
TRY
CALL w.endDocument()
CATCH
DISPLAY "ERROR: ", status
END TRY
END