Since I'm not sure where to post a request for a language enhancement, I guess I'll post it here:
I was working with some functions today and I wanted to have them bubble-up any system errors to their caller. So I tried the following:
What I ended up doing was a bit more wordy. I had to store the result of the function and then test for a non-zero condition before setting an error condition:
So, what I was wondering is this:
Could PB's ERROR statement be changed to allow an "ERROR 0" to not generate any error condition at all instead of mapping ERROR 0 to ERR=5 (illegal function)?
Error trapping is our friend and I can see other circumstances where I might want to set an error condition via the result of a calculation without having to always check for a non-zero condition first before invoking the ERROR statement.
Does anyone else feel this way? Or am I missing a solid reason why the ERROR statement should work the way it currently does?
-Wes
I was working with some functions today and I wanted to have them bubble-up any system errors to their caller. So I tried the following:
Code:
Try ' The function either completes successfully (0) or returns ' the system error (non-zero) it encountered. ' Error SomeFunction(n) Catch ' Bubble-up the system error to the caller. ' Function = Err Exit Function End Try
Code:
Try ' The function either completes successfully (0) or returns ' the system error (non-zero) it encountered. ' intErrValue = SomeFunction(n) If intErrValue <> 0 Then Error intErrValue Catch ' Bubble-up the system error to the caller. ' Function = Err Exit Function End Try
Could PB's ERROR statement be changed to allow an "ERROR 0" to not generate any error condition at all instead of mapping ERROR 0 to ERR=5 (illegal function)?
Error trapping is our friend and I can see other circumstances where I might want to set an error condition via the result of a calculation without having to always check for a non-zero condition first before invoking the ERROR statement.
Does anyone else feel this way? Or am I missing a solid reason why the ERROR statement should work the way it currently does?
-Wes
Comment