Proposal: Extensible exceptions
lemming at henning-thielemann.de
Mon Jul 7 05:47:35 EDT 2008
On Sun, 6 Jul 2008, David Menendez wrote:
> I don't recall calling anything "proper exception handling". I said
> that it's reasonable to report certain programming errors through the
> exception handling mechanism because it allows a running program to
> clean up before it terminates.
You can try to report programming errors to the user - but that's
debugging. Where is the need to mix that with regular exception handling?
>>> If your code divides by zero, you still want any "finally" or "bracket"
>>> clauses to get called before the program terminates.
>> A program which divides by zero is broken and must be fixed. A program which
>> divides by zero but cleans up a bit, is still broken and must be fixed.
>> Cleaning up may make things better, but may also make things worse! Handling
>> errors is the task of Debugging, not that of Exception Handling. I suggest
>> special variants of 'finally' and 'bracket' for bracketing bugs should be
>> located below "Debug" in the module hierarchy.
> Yes, a program that divides by zero should be fixed. If a program has,
> say, locked a file and then encounters an error, are you suggesting
> that the program should crash without unlocking the file?
If your program is buggy, then it may well be that the file to unlock is
already unlocked and deleted. By trying to recover from an error a
division by zero can cause even more severe damages. It is not possible to
handle errors in a way like exceptions, because exceptions are (rare but)
expected situations, that can well be handled. In contrast to that you do
not know the concrete errors in your program, otherwise you would have
fixed them already.
More information about the Libraries