[Pharo-project] Improving Pharo's Exception Hierarchy
Mariano Martinez Peck
marianopeck at gmail.com
Wed Apr 13 10:50:28 CEST 2011
On Mon, Apr 11, 2011 at 4:10 PM, Sven Van Caekenberghe <sven at beta9.be>wrote:
> Hi All,
> I have this idea that I would like to discuss on the next Pharo sprint and
> maybe start to implement if there is some consensus on it.
> It has been mentioned many times before on this list that Object>>#error:
> should be replaced by signalling specific Exceptions in as many cases as
> possible (or where it makes sense). Even today, there was
> http://code.google.com/p/pharo/issues/detail?id=3987 !
> I think the core system should set the example here, by defining a number
> of general purpose exceptions and by using them. Going over #error: senders
> will be a lot of work but can be done in incremental/Pharo steps.
> So I went over the current hierarchy, scanned quickly through their
> references and some #error: senders by fundamental classes and looked at
> some other Smalltalks. I came up with the following very rough draft of an
> extended hierarchy (** marks new exceptions). In between brackets are the
> instance variables. Of course, we have to discuss about naming, instance
> variables and opportunities for reuse and inheritance (could be fun).
> I am no expert on exceptions and would certainly like to learn more.
You probably know the PharoByExample chapter on exceptions, but just in
> I am probably overlooking some aspects. We have to keep this Smalltalk
> like, flexible, dynamic, not start mimicing other languages.
> Any step in this direction will be an improvement over the current
> situation. Really using them correctly throughout the system will take some
> time. Defining the hierarchy could be done rather quickly. Refactoring is
> always possible later on.
> Exception (messageText)
> ZeroDivide (dividend)
> RangeError ** (from, to)
> NaNError **
> FileStreamException (fileName)
> FileDoesNotExistException (readOnly)
> FileExistsException (fileClass)
> FileReadError **
> FileClosedException **
> CannotAccessFileException **
> ReadonlyFileException **
> MessageNotUnderstood (message, receiver)
> NonBooleanReceiver (object)
> SyntaxError ** !exists! (input, position)
> NumberFormatException **
> HeadlessError **
> TimedOut ** (object, operation, timeout)
> IllegalOperation ** (operation, object)
> SizeMismatch (objects)
> LowMemory ** (percentageFree)
> SubclassResponsibility ** (message, receiver)
> NotYetImplemented ** (message, receiver)
> CannotInstanciate ** (class)
> ReadOnlyObject ** (object)
> OutOfFreeSpace ** (object, size)
> InvalidArgument ** (message, receiver, argument)
> NotIndexable ** (object)
> NoKeyedAccess ** (object)
> NonIntegerIndex ** (receiver, index)
> SubscriptOutOfBounds ** (receiver, index, from, to)
> NotFoundException ** (receiver, object)
> KeyNotFound **
> ValueNotFound **
> ElementNotFound **
> StreamException (stream)
> PositionError ** (index, from, to)
> EndOfStream **
> BeginOfStream **
> All feedback is welcome.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pharo-project