[Pharo-project] Improving Pharo's Exception Hierarchy

Camillo Bruni camillo.bruni at inria.fr
Wed Apr 13 14:52:55 CEST 2011


What I've seen so far and I like is to use small helper methods to signal exceptions:

Dictionary >> at: aKey
	self keyNotFound: aKey.

"helper method to fill the exceptions params"
Dictionary >> keyNotFound: aKey
	KeyNotFoundException signalWithKey: aKey

"helper to signal an Exception"
KeyNotFoundException class >> signalWithKey: aKey
	self new
		key: aKey;

At least one of the helper methods should be present to make the code more readable, I think.

And as Mariano pointed out, there should be a convention on the naming: I am still not sure about suffixing the exception classes with "Exception", but I guess this is a good thing to do. Though I must say that I omitted it so far ;) and just put the verb there, but that can be easily changed.

The exception hierarchy looks nice ;), I think in this matter we can learn a bit from Java.

And I would certainly like to see these error messages infect the whole system ;).


On 2011-04-13, at 11:03, Sven Van Caekenberghe wrote:
> On 13 Apr 2011, at 10:50, Mariano Martinez Peck wrote:
>> You probably know the PharoByExample chapter on exceptions,
>> but just in case: https://gforge.inria.fr/frs/download.php/26600/PBE2-Exceptions-2010-03-02.pdf
> Seems like the right kind of preparation, I will reread it.
> I love written documentation.
> Thanks!
> Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/pharo-project/attachments/20110413/c5af5269/attachment.htm>

More information about the Pharo-project mailing list