I'm a long-time Pascal/Delphi programmer, but have never used exceptions. Now that I need them, I can't get the simplest exceptions to work rationally. Here is a (hopefully) trivial test example
Function Funky(DivBy : integer) : integer;
ShowMessage('Going into Funky Routine DivBy = ['+inttostr(DivBy)+']');
result := 42 div DivBy;
on EDivByZero do result := 0;
on Exception do result := 0;
else result := 0;
end; // of try
ShowMessage('Leaving Funky Routine Result = ['+inttostr(result)+']');
I have tried every permutatiuon of the above exception clause, and in every case where DivBy is zero, I get the first ShowMessage and then an exception message raised by Delphi - completely ignoring my
attempt at handling the exception and aborting the program. (I realize that the above example is wildly redundant - I think that the two "on"s and the else should each catch the exception separately.
I hope that I am just missing something terribly obvious.
*** While writing this question, I went back and tried to execute the program outside the IDE just for the heck of it, and the exception handling worked correctly. Is this all it was? - that the IDE takes over exception handling? Can this "feature" be turned off? ***