[Gambas-user] Catch Not Catching or is bypassed with the Finally...

KKing kicking177 at gmail.com
Wed Jun 26 19:16:37 CEST 2019


Is this correct behaviour while stepping through code in IDE?

In example below if an EOF is encountered on the Read, it jumps from the 
read to the Finally statement and processes as if no error, though I 
realised issue because the iResponse is -1.
Shouldn't it jump to the Catch and depending on code then execute the 
Finally just before leaving?

If I comment out the Finally, it does jump to the Catch and gives the 
expected error details.

<<
Sub ReadFile(hfile as File) as integer

     Dim iResponse
     iResponse = -1

     Seek #hfile, 30
     Read #hfile, someContent, 80
     iResponse = 0

Finally
     Try hfile.Close
     hfile = null
     return iResponse

Catch
     Print Error.Code
     stop

End
 >>

K.



More information about the User mailing list