All exceptions thrown by JDAPI extend JdapiException
, which in
its turn extends java.lang.RuntimeException
. This means that almost
every JDAPI method can throw an exception, and that you are not required to
specifically write try
/catch
code for these exceptions.
However, it is good practice to do this. As a suggestion, you could follow each
try...
block with several catch...
blocks, catching
first the JDAPI exceptions and then more generic exceptions.
JDAPI exceptions are:
JdapiException
the base type; thrown in many cases. May
be thrown by the underlying Forms code on failing to create Forms objectsJdapiIllegalStateException
thrown by any Forms object
class when a method is called and the class instance does not reference a
valid Forms object (for example, after the Forms object has been destroyed)JdapiUnsupportedOperationException
thrown by the remove()
method of JDAPI iterators which do not support the functionality, and by the
compile()
method of the PlsqlLibrary
classJdapiStatusException
this subclass of JdapiException includes
the status code associated with the event. These status codes are held as
members on JdapiTypes ending with _STID
and can be retrieved off of the exception by using the getStatusCode()
method.FormModule fmb = FormModule.open(filename);
try
{
@ fmb.compile();
}
catch(JdapiStatusException e)
{
if(e.getStatusCode() == JdapiTypes.WARN_STID)
{
// this is a warning, the .fmb has still been created.
}
else
{
// the compilation failed - process the error.
}
}
catch(JdapiException e)
{
// the compilation failed - process the error
}