Internal procedures / error-handling

Hawelka

New Member
Hello all!

Unfortunately it is not possible, to define error-handling-options on an "procedure" - Statement.

e.g.
Code:
Procedure foo on error undo, return error /* something */:
So we have to define one further block, to make the error-handling.
Which makes the structure of internal procedures deeper than we want.

e.g.
Code:
Procedure foo:
   Do on error undo, return error /* something */:
What is your way, defining error-handlings on internal procedures?
I would like to structure my Programms in this style:

Code:
Main:
Do on error undo, retry:
   if retry then
   do:
      /* log error-messages and return */
      ...
   end.

   run sub1.
   run sub2.
   run sub3.
End.
Thanks in advance!
Erich!
 

Cringer

ProgressTalk.com Moderator
Staff member
We tend to use

Code:
    proc:
    DO  ON ERROR UNDO, RETRY proc
        ON STOP UNDO, RETRY proc:
        IF RETRY  THEN  DO:
            RUN msgfrmmp.p
                ( OUTPUT lvMsg ).
            UNDO, RETURN ERROR lvMsg.
        END.
        <blah>
    END.

then in the calling procedure

Code:
IF ERROR-STATUS:ERROR OR ERROR-STATUS:NUM-MESSAGES > 0 THEN
DO:
    {appsrvmsg.i}
    RETURN ERROR.
END.


msgfrmmp.p extracts the error message. {appsrvmsg.i} decides whether to put the message to screen or a log file.
 
Top