From: Charlie McLean To: All
We are a small shop and are establishing coding standards, finally. Having looked at other examples of standard error handling, I'm hard pressed to understand the value of standard program level MONMSGs. Seems like the examples in Qusrtool are certainly interesting coding exercises but only allow the program to die quietly without any break *ESCAPE messages. Except for unattended processing, wouldn't you want a CPF9999 to blow up? I'm afraid that the other way is too quiet. Anybody have a standard error-handling routine for CL?
From: Ernie Malaga To: Charlie McLean
I haven't looked at QUSRTOOL that closely, but what I use for standard error handling is a command I wrote to forward program messages to the caller. I've written two articles about AS/400 messages which will appear in the March and April issues of MC. The April issue will also have the command I've mentioned.
Essentially, what I do is shown in 3.
Essentially, what I do is shown in Figure 3.
Actually, to be doubly sure, the RCVMSG/SNDPGMMSG pair should be coded within a loop to be sure you're forwarding all messages to the caller, the last of which MUST be an *ESCAPE message. It is this *ESCAPE message that informs the caller that the program abended.
From: Michael Russell To: Charlie McLean
First, based on various human factors references, its just plain inconsiderate to the users to not have a soft mechanism to handle those unexpected errors. To cause the Program Messages display to appear and force the user to reply to some message is poor programming. Sorry, if I sound very blunt on this topic, but I think as professionals we should not inflict our users with the Program Messages display.
Second, a previous message showed a common method of echoing those unexpected errors to the calling program. This method allows the program to fail softly and inform the calling program of the problem. However, I would like to suggest some changes:
a) Instead of echoing the received message, send a new message like UDU9999 as *ESCAPE to *PRV. This message would say something like "Unexpected error in program ...".
b) I would use a service program to perform the above processing. This service program would do the following: run DSPJOB OUTPUT-(*PRINT) to print job information, run DSPJOBLOG to print the job log, run SNDMSG to some message queue which programmers can monitor (this would reduce the chance that the user fails to report the problem), and send the
"Unexpected error" message to the failed program's caller.
c) I would strongly recommend using message subfiles in the interactive programs. As a result, the "Unexpected error..." message would appear in the subfile, and the calling program would not have to worry about sending some error message.
TechTalk: CL Standards for Error Handling
Figure 3 One method to forward messages
Figure 3: One Method to Forward Messages DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(80) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(10) DCL VAR(&MSGTXT) TYPE(*CHAR) LEN(256) DCL FILE(PROMPT) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) /* program processing goes here */ ERROR: RCVMSG MSGTYPE(*EXCP) MSGF(&MSGF) MSGFLIB(&MSGFLIB) + MSGID(&MSGID) MSGDTA(&MSGDTA) MSG(&MSGTXT) IF COND(&MSGID *NE ' ' *AND &MSGTXT *NE ' ') + THEN(DO) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) + MSGDTA(&MSGDTA) MSGTYPE(*ESCAPE) ENDDO ENDPGM
LATEST COMMENTS
MC Press Online