Question
How Do We Know Which Exceptions Each JLink Method Throws?
Hi Everyone -
I'm updating a JLink application and want to apply specific handing
for each situation where reading a parameter might fail: The parameter
doesn't exist, the value doesn't have the expected type, and so on.
Of course, these statements are already surrounded by a try/catch
statement which catches the superclass jxthrowable, like this:
try {
Parameter param = model.GetParam( paramName ) ;
if ( param != null ) {
ParamValue valObj = param.GetValue() ;
value = valObj.GetStringValue() ;
} else {
value = " ;
}
} catch ( jxthrowable exc ) {
value = " ;
}
So what I want to do is create a separate catch statement for each
type of exception, like this:
try {
Parameter param = model.GetParam( paramName ) ;
if ( param != null ) {
ParamValue valObj = param.GetValue() ;
value = valObj.GetStringValue() ;
} else {
value = " ;
}
} catch ( XInvalidModelItem exc ) {
// Do something about a missing parameter
} catch ( XBadGetParamValue exc ) {
// Do something about a bad parameter value
} catch ( jxthrowable exc ) {
// Handle all other exceptions here
}
Unfortunately, I can't find any documentation that says which specific
exception each method might throw. The exception class names I used
in the catch statements above are just my wild guesses which exceptions
might be thrown
What I had hoped for was documentation that states which exceptions a
given might throw and the reason for doing so. This isn't an outrageous
expectation; Javadoc provides the @throws tag to document this information
in method's source code:

