Initializing help system before first use

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.