Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / CATCH question

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. CATCH question
#12595
Posted by: PeterJ 2008-12-30 20:39:04
it took me many years to understand the Catch behaviour, but in the end ...

I have a main procedure (actually a variable server), which can call various sub procedures. To avoid a termination of the server by a poorly written sub procedure, I use the following sequence:

exec:
USE ARG exec, p0,p1,p2,p3,p4,p5 
CALL preparekept
DO
   CALL [exec](p0,p1,p2,p3,p4,p5) 
   CATCH NOVALUE
      CALL ERROR('Novalue Error occured')
   CATCH SYNTAX
       CALL ERROR('Syntax Error occured')
   CATCH ERROR
       CALL ERROR('Error condition occured')
   CATCH FAILURE
       CALL ERROR('Failure condition occured')  
END  

Am I correct, that there is no common "error" clause which includes all the used catch conditions?

Regards

Peter
Message2.
#12598
Posted by: Jeff Glatt 2008-12-30 23:17:50 Last edited by: Jeff Glatt 2008-12-30 23:20:32 (Total edited 1 time)
Right. There is no CATCH statement that catches all 7 possible "REXX conditions" (ie, NOVALUE, HALT, ERROR, FAILURE, SYNTAX, NOTREADY, and USER). Each condition must be caught on its own. But since the CONDITION() function may return different information for different conditions, if you wanted to report or examine the problem, you'd use CONDITION() in different ways per condition anyway. So unless you're writing "do nothing" error handling, you want to examine (ie, CATCH) each condition separately.

Note that ERROR and FAILURE conditions will not terminate your server script (nor the child script). If those are ignored, then you're just not informed when those issues arise. (So for example, you'd have to do manual error checking whether an add-on DLL function succeeded, or suffer the consequences if you assume success. A consequence may be that, later on in the script, having ignored that error may cause some other, more severe condition to be raised, such as SYNTAX or NOVALUE. You never know how missing error handling will manifest itself later). Additionally, note that if you don't specifically CATCH FAILURE, but do CATCH ERROR, then any FAILURE gets automatically converted to ERROR. (So CATCH ERROR suffices for both ERROR and FAILURE conditions).

So too, NOTREADY won't abort anything if you don't CATCH it.

USER condition has a CATCH USER ANY statement to catch all instances of USER condition. But of course, you won't ever encounter that unless the child script explicits uses RAISE to trigger a USER condition. And like NOTREADY, FAILURE, and ERROR, an ignored USER condition (from your child script) won't end your server script anyway.

HALT happens only if the enduser (or perhaps operating system) explicitly wants your script to end. Normally, you don't bother handling this because you want to honor the user's wishes and terminate.

Basically, around the call to run your child script, just CATCH NOVALUE and CATCH SYNTAX (and maybe HALT) in your server script if you want to ensure the latter keeps running no matter what happens in the child.

Incidentally, you don't need any instructions after the CATCH. You can leave it empty if you truly just want "do nothing" error handling. (Additionally, the CALL keyword is obsolete in Reginald. Let's do our best to banish it from the face of the earth. CALL was a bad design decision).
exec:
USE ARG exec, p0,p1,p2,p3,p4,p5 
preparekept()
DO
   [exec](p0,p1,p2,p3,p4,p5) 
   CATCH NOVALUE
   CATCH SYNTAX
END
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0