[Pharo-project] Improving Pharo's Exception Hierarchy

Alexandre Bergel alexandre.bergel at me.com
Mon Apr 11 19:58:45 CEST 2011


Hi Sven,

+1
The exception hierarchy needs some work, indeed. 
If you make all your new exception a subclass of Error, you should not have a problem with the existing handler I imagine.

Alexandre



On 11 Apr 2011, at 10:10, Sven Van Caekenberghe 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. 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)
>  Abort
>  Error
>    ArithemticError
>      ZeroDivide (dividend)	
>      FloatingPointException
>      RangeError ** (from, to)
>      NaNError **
>    FileStreamException (fileName)
>      FileDoesNotExistException (readOnly)
>      FileExistsException (fileClass)
>      CannotDeleteFileException
>      FileWriteError
>      FileReadError **
>      FileClosedException **
>      CannotAccessFileException **
>      ReadonlyFileException **
>    MessageNotUnderstood (message, receiver)
>    NonBooleanReceiver (object)
>    OutOfMemory
>    Halt
>      AssertionFailure
>      BreakPoint
>    SyntaxError ** !exists! (input, position)
>      NumberFormatException **
>    HeadlessError **
>    TimedOut ** (object, operation, timeout)
>    VerificationException
>    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.
> 
> Regards,
> 
> Sven
> 
> 
> 

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.








More information about the Pharo-project mailing list