I am working on an application in which many of the functions employ TRY ... CATCH blocks to catch custom errors I throw with the ERROR statement. When I run my application in debug mode (Run -> Compile and Debug) I get the following error in my CATCH block where I test the current error code with the ERR or ERRCLEAR functions:
However, in the help file it clearly states for ERR and ERRCLEAR:
If an error code of 151 is valid, why do I get the error mentioned above when running in debug mode? It doesn't prevent me from testing my application but it is incorrect and rather annoying.
The following code demonstrates this issue:
I am using PB/Win 9.01.0100.
Break on error 151:
Not a valid PowerBASIC error code. Probable memory corruption.
Not a valid PowerBASIC error code. Probable memory corruption.
Valid run-time error values are in the range 1 through 255. Attempting to set an error value (with the ERROR statement) outside of that range will convert the value to a run-time Error 5 ("Illegal function call").
The following code demonstrates this issue:
Code:
'Run this code in debug mode to see the problem. %MyCustomErrorCode = 151 Function PBMain () As Long Try Error %MyCustomErrorCode Catch Select Case As Long ErrClear Case %MyCustomErrorCode ? "My custom error thrown." End Select End Try Function = 1 End Function
Comment