×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Hello Jorge,
I have been told that in the case of an exception Java type we have
to manipulate the Java exception in a different way Is it possible to
catch that Java exception error in RPG and how would you recomend to
do it?
Under the covers, the RPG program is calling the JNI API to run your
Java routine. After each JNI call, it has to call a JNI routine called
ExceptionCheck (or ExceptionOccurred() one of the two) to determine if
the call succeeded or failed, and then it retrieves details of the
exception, and ExceptionClear() to clear the exception. The code to do
all of this is generated by the compiler.
When an exception occurs, the generated code then sends an *ESCAPE
message to the RPG program so that your code can detect that something
failed. The important parts of the exception are sent as MSGDTA in that
*ESCAPE message.
The calling RPG program can use the MONITOR opcode to catch the
exception, and can then retrieve the message with QMHRCVPM read the
MSGDTA to find out information about the exception.
If that support isn't sufficient for your needs, your options are:
a) Change the Java routine to NOT throw an exception, but instead,
return error information via parameters/return values.
-or-
b) Call the JNI routines directly instead of using RPG's support for
calling Java. Then you could control the exception handling yourself.
-or-
c) File a DCR with IBM and ask them to change the way they handle
exceptions to make more information available to the RPG program
directly (instead of going through the message) and hope they do it.
(But this would likely take a long time to happen, if they even agreed
to do it.)
So I guess my question is... what's wrong with using RPG's MONITOR
op-code? From your message, you already knew it was a possibility, but
discounted it for some reason. What is that reason? Why not use MONITOR?
As an Amazon Associate we earn from qualifying purchases.