× 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.



On 6/21/2013 5:54 PM, John Yeung wrote:
...
The reason I ask is that in languages like Java and Python, it is
encouraged to catch as specific an exception as is appropriate, so
that you don't inadvertently mask errors that really *should* halt
your program (or bubble up to the caller). But those languages have
somewhat self-documenting class names to use, so I've found their
exception-handling code fairly readable.


I think the same reasoning applies to RPG.

Are *PROGRAM and *FILE sufficiently specific in real-world RPG code?
If not, is the standard practice to give meaningful names to the
status code literals in the D-specs (as I've seen recommended for
indicators and indeed for most literals of any kind)?

I use named constants to name the status codes.

For localized code with expected errors, I usually code a MONITOR with one or more specific ON-ERRORs, but no catch-all. In those cases, I rarely code a catch-all, since I don't want to get control at that point if I have an unexpected error. I'd rather some more general part of the code get control.

monitor;
realdate = %date(string : *ISO);
on-error STATUS_112_bad_date;
realdate = some default value;
endmon;
-- more code here --

For unexpected errors, I usually just code a single ON-ERROR with no operands.

monitor;
-- all the code in my procedure --
on-error;
-- process the unexpected error --
endmon;

I guess there might be cases where I'd have different processing for file errors vs program errors, but I can't think of any off the top of my head.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.