|
We adopted the error handling mechanism of the IBM APIs. Parameter
o_errMsg is defined as *OMIT and *NOPASS. It is always the last parameter
in the parameter list. The source code dealing with the error looks like
this:
// If the message parameter (o_errMsg) has been passed, ...
if (%parms() >= %parmnum(o_errMsg));
// ... check if it has been omitted:
// When it has been omitted, ignore the error, else ...
if (%addr(o_errMsg) <> *null);
// ... return the error to the caller
o_errMsg = errMsg;
endIf;
else;
// ... else send an escape message
if (errMsg.msgID <> '');
sndPgmEscMsg(errMsg);
endIf;
endIf;
- Thomas.
-----Ursprüngliche Nachricht-----
Von: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] Im Auftrag von
Barbara Morris
Gesendet: Mittwoch, 20. Februar 2019 20:07
An: rpg400-l@xxxxxxxxxxxxxxxxxx
Betreff: Re: converting to service program etc
On 2019-02-17 6:45 PM, Craig Richards wrote:
A few other things you end up having to think about when you start usingexpression -
sub-procedures:
- You now want to return a value to be sensibly used in an
but how do you tell the caller when something goes wrong?a
- Generally I THROW an error in the sub-procedure and catch it in
monitor block surrounding the sub procedure call (at some level)If you
haven't seen this technique before it's a nice one to know.
Another related way to handle this issue is to also add an optional
parameter to receive error information. If the parameter isn't passed,
send the exception.
Here's an RPG Cafe blog post I wrote about this issue a few years ago.
https://www.ibm.com/developerworks/community/blogs/b542d3ac-0785-4b6f-8e53-f72051460822/entry/return_code_or_exception?lang=en
--
Barbara
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
IMPORTANT NOTICE:
This email is confidential, may be legally privileged, and is for the
intended recipient only. Access, disclosure, copying, distribution, or
reliance on any of it by anyone else is prohibited and may be a criminal
offence. Please delete if obtained in error and email confirmation to the
sender.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
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.