Exception Handling

BlitzMax Forums/BlitzMax Programming/Exception Handling

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Can anyone please tell me why the following does not throw an exception, it just keeps running well beyond the end of the file


'exception test

SuperStrict


Local infile : TStream = ReadFile("<replace with any short text file>") 
Local count : Long
Local tvar : String

If Not infile
	Print "not loaded"
	End
End If



Repeat
	
	Try
		tvar = ReadString(infile , 10)
		Print tvar
		count :+ 1
	
	Catch a : Object
			
		Print a.ToString()
		End
		
	EndTry
	
	Print count
	
Forever


As I understand it, As soon as any of the stream reading command get to the end of the file they throw a TStreamReadException which my try block should pickup, but it does not. What am I doing wrong. I plan to use the block to detect errors in case of a short file.

Cheers.