Exception Hierarchies

Norton, Chris chrisn at Kronos.com
Mon Aug 16 20:29:27 UTC 1999


Hi Folks.

This response was written with the philosophy: "1) open mouth. 2) insert
foot to kneecap."  So, Alan, I am NOT trying to criticize you.  :-)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Alan Lovejoy [sourcery at pacbell.net] wrote:
[...snip...]
> Ah, then perhaps the problem is simply that "Error" is misnamed.
> 
> I suggest the following hierarchy:
> 
> Exception (the root class, takes no action if no handler is found,
> proceedable by default)
> 	DefaultHandlerException (takes some default action if no handler is
> found)
> 		HandlerRequiredException (raises NoHandlerException if no
> handler)
> 			ErrorException (root of all errors, not proceedable
> by default)
> 			WarningException 
> 		NoHandlerException	(raised when no handler is found for
> a 
> 					HandlerRequiredException, opens
> 					default "UnhandledException"
> notifier
> 					if no handler found for NoHandler
> exception)
> 		ControlException 
> 			HaltException
> 			UserInterruptException 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm not an expert on Exception handling, but I sure find it handy to say:

    ["some risky code"] on: Error do: ["clean up after my code died"].

I think that Error is a good "catch all" name for (near-)fatal exceptions.
Having said that, I'd like to point out that in VSE, there is an exception
handler called KeyboardInterrupt() that happens when you hit Ctrl-Break.
This interrupt is subclassed from Notification(), which is not subclassed
from Error.  Perhaps the Halt and UserInterrupt should be subclassed from
Notification() in Squeak.  After all, they aren't really errors.  They are
simply interruptions that can (usually) be resumed.

Just my $0.02.  Cheers to Craig Latta, the folks at TFEI and to Steven Pope
for making Exceptions happen in Squeak!!

---==> Chris





More information about the Squeak-dev mailing list