Exception handling
When an error occurs within a Java method, the Java Virtual Machine will throw an exception. From Mosel, you can check whether your last call to Java threw an exception by calling the jvmstatus function; a return value of false indicates an exception. When jvmstatus is false, the jvmgetexceptionclass function will return the class name of the exception (e.g. java.io.FileNotFoundException) and the jvmgetexceptionmsg function will return the exception's message. For example:
model myModelExc uses 'mosjvm' jvmcallvoid('com.fico.MyClassName.parseMyInputFile', 'inputfile.dat') if jvmstatus=false then setioerr('Encountered Java error of type: '+jvmgetexceptionclass+", message: "+jvmgetexceptionmsg) end-if end-model
If you set the parameter jvmdebug to 'true', the stack trace of any exceptions thrown by your calls to Java will be written to the Mosel model's error stream.
If you set the parameter jvmabortonexception to 'true', the Mosel model will immediately terminate with a runtime error if any Java method throws an exception.
© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.