Convention regarding exceptions

Peter Schuller peter.schuller at infidyne.com
Wed Jan 24 23:43:49 UTC 2001


I was just about to re-submit the changes to the ConnetionQueue I made when
I decided to improve it some more before doing so. (Thanks for all the info
on the submission process!)

I know have a question regarding Squeak/Smalltalk exception usage. I know
what I want to do, but I don't know if it would be deemed appropriate.

ConnectionQueue now has a waitForConnectionIfDestroyed: method that will
block forever until a socket becomes available, or evaluate the given block
if the receiver is destroyed by another process.

But I still have waitForConnection. However I am not sure what to do
about the default behavior should the receiver be destroyed while this
method is blocking. First of all I would personally opt for throwing an
exception. After all, if the calling code wanted to handle the case of a
destroyed socket, it can use the waitForConnectionIfDestroyed. If
not, and the receiver is destroyed anyway because of a bug, an exception that
actually says that the ConnectionQueue was destroyed is more informative
that the generic error which will ensue if it just answered nil.

Now, here is my dilemma: Coming from a Java background my first reaction is
to create a new Exception subclass (ConnectionQueueDestroyedException for example).
This will enable the calling code to handle this particular exception very
easily simply by relying on the class matching functinality of Squeak's
exception handling (i.e.: [ .... ] on: ConnectionQueueDestroyedException do:
[ ... ].).

However, looking at the existing API, Exception classes are *very* sparse;
it seems most errors are signaled by a normal Exception with the appropriate
text. Is this also becaue of historical reasons (i.e. exception handling not
always being supported by Squeak), or would creating a new Exception
subclass just for "my" little case go against what Squeak:ers want?

I think there is every reason to create a new Exception subclass; but
searching for "Exception" in the class browser yields only 5 classes that
appear to be actual exception types. This makes me apprehensive.

-- 
/ Peter Schuller, InfiDyne Technologies HB

PGP userID: 0x5584BD98 or 'Peter Schuller <peter.schuller at infidyne.com>'
Key retrival: Send an E-Mail to getpgpkey at scode.infidyne.com
E-Mail: peter.schuller at infidyne.com Web: http://scode.infidyne.com





More information about the Squeak-dev mailing list