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



If you are looking for a standard exception handler if you look at
www.sourceforge.org/projects/iBuild you will find a make tool.

Part of that project is a service program called XVERRH, my standard error
handler.

Written 20 years ago and upgraded over the years, it is now written as 100%
Free. ,This utility allows you to throw an exception. It is little
different in that it stores the exception in a linked list so that you can
retrieve the exceptions at a higher level.

Example,

Program A calls service program S1 which calls service program S2 which
calls service program S3.

An exception occurs in S3. You need to report the exception to Program A so
you call XVERRH_Throw, the error is stored in a linked and an escape
message is sent to the caller.

S2 receives the exception and calls XVERRH_Throw to report that error and
again that is stored in the linked list and escape message sent to S1.

S1 receives the exception and reports the error by calling XVERRH_Throw and
again is stored in the linked list and sends an escape message to Program
A.

Program A receives the exception. At this point, Program A can call
XVERRH_GetMessage.

XVERRH_GetMessage retrieves the first message from the and removes it and
keeps calling XVERRH_GetMessage until there are no more messages.

Thus, the top level of the call stack can report what caused the error.

Anyway, I learned over 20 years ago to always report errors by exception
(Escape Messages). Never use a return value because without exception the
return value will not be examined and processing will continue.

You can if you wish use a monitor and trap the error but you must do that
conscientiously.

XVERRH has the following functions:

XVERRH_Thorw - Throws error and stores message in linked list.
XVERRH_Rethrow - Rethrows message from a lower level to higher level.
XVERRH_AddMessage - Add message to linked list.
XVERRH_GetMessageCount - Gets count of messages in the linked list.
XVERRH_GetLastMessage - Gets last message in list without removing from
storage.
XVERRH_GetMessage - Get first message from linked list and removes from
linked list.
XVERRH_BuildConditionToken - Builds an ILE Condition Token.

I will separate into a separate project if requested but have been ill
lately and having a hard time getting things I promise done.

On Fri, Mar 5, 2021 at 10:12 AM Barbara Morris <bmorris@xxxxxxxxxx> wrote:

On 2021-03-04 7:34 a.m., Buck Calabro wrote:
On Wed, 3 Mar 2021 at 17:11, Dave <dfx1@xxxxxxxxxxxxxx> wrote:

... In my opinion, when people in your group have a calm discussion
about the relative merits of C/SQL-style return codes vs Java/IBM
i-style exceptions, you're moving in the right direction for creating
a system that is robust. No, it's really not possible to 'handle'
every single error that can occur, but when I *think* about doing that
as a standard way of building an application, the results turn out
better for me. ...

I wrote a blog post in the RPG Cafe about the issue of return code vs
exceptions for a procedure, and how to write a procedure that allows the
caller to choose: https://ibm.biz/rpgcafe_return_code_vs_exception

(Actual URL is https://www.ibm.com/support/pages/node/1119309)

--
Barbara

--
This is the RPG programming on IBM i (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@xxxxxxxxxxxxxxxxxxxx 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 thread ...

Replies:

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.