Forum Post: RE: Gotchas with ROUTINE-LEVEL in ChUI procedures?

  • Thread starter Thread starter Laura Stern
  • Start date Start date
Status
Not open for further replies.
L

Laura Stern

Guest
Not that's not what I said. The whole point of using ROUTINE-LEVEL ON ERROR UNDO, THROW is just what it says - to throw an error to the caller rather than handling it locally. So what you just described is expected. ERROR-STATUS:ERROR in the caller will be different depending on which routine you called (the one with or without the ROUTINE-LEVEL statement). I was talking about that the ROUTINE-LEVEL (or BLOCK-LEVEL) statements should have no affect on statements that use NO-ERROR or blocks that have explicit error directives. These things are explicit and we will do what the code says. The ROUTINE-LEVEL (or BLOCK-LEVEL) statements only change the default behavior - i.e,. what happens without NO-ERROR or with no explicit ON ERROR clause. When I said there is a bug I was referring to the first example in this thread with this statement: cc = string( 999, " 9" ) no-error. But I was just playing with this. Oh! Now I know what's going on. THERE IS NO BUG. Here's what's happening: Some of the older constructs in the language that have error conditions put up an error message but actually treat the condition as a warning, not an error. This is mostly true of handle-based methods. I didn't realize that the STRING built-in function is also this way. So yes, if you execute that assignment statement above and you look at the ERROR-STATUS handle, ERROR will be No, but NUM-MESSAGES will be 1. This is what you get for warnings. However, we decided that this behavior is not really correct. And yet we could not change this behavior without breaking people's code. But when we introduced structured error handling, we decided that people were now changing their code and having to re-factor all of their error handling code. So we took advantage of this. Now if the block is governed by structured error handling constructs, we will do the right thing - which is to treat a conditinon causing an error message as an error, not a warning!! So when using the ROUTINE-LEVEL statement you are using structured error handling and the STRING function will raise an error. If you are NOT using ROUTINE-LEVEL, the STRING function as shown will generate a warning. Even without ROUTINE-LEVEL, adding a CATCH block would have the same effect.

Continue reading...
 
Status
Not open for further replies.
Back
Top