|
Hi Paul,
I was just wondering what you meant by "on-error catches all message IDs. In fact, that's the problem with it! it doesn't give you a change to specify that some of them are "unhandled",
As you, yourself, pointed out, on-error will catch everything. It not only will catch the messages that you send with the throw() subprocedure, but it'll also catch an MCH1202 or some other error that you may not have expected.
For example, let's say I'm writing a subprocedure to delete a file. The caller might expect that the file doesn't exist, so it might want to monitor for CPF1205, and if that's the only error that gets thrown, continue normally.
On the other hand, if something totally unexpected occurs, for example an MCH3601, I might want NOT want to catch it. OR I might want to let another program that's higher up on teh call stack decide whether or not it should handle the error.
You can do that easily in CL with the MONMSG command, but it's not so easy in RPG, because you can't monitor for specific msgid's, only for RPG status codes.
When you find an exception like this that you DON'T want to handle (but would prefer the OS's error handler to kick in) then what you have to do in RPG (because there isn't a better alternative) is send a new *ESCAPE message.
Because the procedure that you called can return ANY escape message, the easiest way to handle these "unexpected exceptions" is to use the QMHRSNEM API. That API will look up the last exception that occurred, and it'll re-send it to your caller.
That way, when the MCH3601 occurs in a subprocedure that I called, I call QMHRSNEM and the exact same MCH3601 message gets sent to my caller. It's very much like the way ILE would've propagated the error message up the call stack if I had not caught the error.
I posted an example of the QMHRSNEM API to this mailing list in the past. Here's the link to where I posted that example:
http://archive.midrange.com/rpg400-l/200510/msg00610.html I hope this explanation was better.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.