Surviving Multiple Unhandled Memory Exceptions?

BlitzMax Forums/BlitzMax Beginners Area/Surviving Multiple Unhandled Memory Exceptions?

WendellM(Posted 2005) [#1]
In trying out error handling, I've gotten the hang of Try/Throw/Catch and Assert (at least I think so <g>). I've found that any number of Thrown/Asserted errors can be dealt with, but that only one caught Unhandled Memory Exception can be survived: a program continues to run after catching one, but quits if a second occurs.

Perhaps that's indeed intentional: something unknown went wrong, so you have one chance to end gracefully (and you're not supposed to try to keep running as though all were well). Or is there a way to keep going (hopefully safely)?

In the example below, negative numbers are thrown (not a real error, but it simulates one) which works fine - catch 'em all day and the program keeps running. The division by zero is deliberately not avoided which results in an Unhandled Memory Exception. This is caught the first time and you can continue, but entering zero a second time abruptly ends the program.

Is there a way to survive multiple Unhandled Memory Exceptions?

'Entering a positive number works fine (except for 999 which quits as intended)
'Entering a negative number is a caught "error" and program continutes fine
'Entering zero is Unhandled Memory Exception - program will continue once, but quits on a 2nd zero
'Uncommenting Assert fixes that, but I'm looking for how to handle multiple Unhandled Memory Exceptions

Strict

Local a:Int

Repeat

	Try
		a = Int( Input() )
		If a < 0 Throw "Don't Be Negative"
		'Assert a <> 0, "Div by Zero"
		Print ( 100 / a )
	Catch exception:Object
		Print "caught " + exception.ToString()
	EndTry

	FlushMem

Until a = 999

Print "Done."
Delay 250
End