[Gambas-user] "If Error" is ambiguous

Benoît Minisini g4mba5 at gmail.com
Mon Sep 9 22:32:14 CEST 2019


Le 09/09/2019 à 17:19, Christof Thalhofer a écrit :
> Am 09.09.19 um 16:14 schrieb T Lee Davidson:
> 
>> It does seem logical that Error.Clear should also reset the error flag.
> 
> Okay, that's what I think, too. It's not understandable that after an
> Error.Clear Error still shows true.
> 
> But will a correction break a lot of existing code? I don't think so.
> Who was aware of that, checked for Error.Code. Who was not, produced
> potentially unreliable code which should have caused errors meanwhile.
> 
> The code of Gambas itself is full of "If Error Then".
> 
> Alles Gute
> 
> Christof Thalhofer
> 

The error flag is set once the TRY instruction has been executed.

The error exception management code does not care with that flag, this 
is why Error.Clear() does not clear it. Actually nothing clears that 
flag, except a new TRY instruction.

I don't think it's a problem if Error.Clear() would clear the flag.

Anyway, the 'If Error Then...' was intended to  be used just after a TRY 
instruction and only in that occasion.

Maybe the compiler should raise a warning if we are not in that case, if 
possible.

Regards,

-- 
Benoît Minisini


More information about the User mailing list