> I enjoyed the chapter :-). It was very informative, and illustrated  
> yet again how flexible Smalltalk can be. Is there any particular  
> reason why this 'essential' chapter was not included in the first  
> edition of Pharo by Example?

lack of time was the reason.

> I also have a question about the contents. In chapter '1.14 Catching  
> sets of exceptions' it is explained how catch a set of exceptions  
> but not how to define a different handler on each exception. For  
> instance i want to handle a more specific FileDoesNotExistException  
> in a different way than a more general FileStreamException, or even  
> Exception.  The way i can do this, i see, is to test which type of  
> exception is coming into the do: block and execute appropriate code.  
> This is a very bad solution. Or secondly, to create nested on: do:  
> blocks with the most specific exception as inner block. This seems  
> better, but is kind of verbose.
> Is there another way to solve this problem?

Visualworks uses HandlerList for this.
One of the think you can do, is
   * either to nest block handlers [[ ex ] on: Error1 do: [:ex|...]]  
on: Error2 do: [:ex|...]. But in that case you should take care of  
inheritance relationship between Error1 and Error2. It does not work  
for any Error1 and Error2 classes
   * you can use a double dispatch on the exception

Cheers,
Alexandre


>
> Kind regards,
>
> Bart
>
> 2009/11/23 Stéphane Ducasse <[email protected]>
>
>
> Enjoy I had a lot of fun writing it when my family went to the  
> swimming pool and I could concentrate :)
>
> Stef
>
> On Nov 23, 2009, at 9:05 AM, Bart Gauquie wrote:
>
> > Dear all,
> >
> > I've been searching the Pharo by Example book about how to handle  
> Exception, Error, ... in Pharo.
> >
> > I've found some information about it in the SUnit chapter, in  
> method 7.11: Catching test case errors and failures; this is only a  
> small fragment however.
> >
> > Is there any chapter planned about this topic? It would be very  
> useful i think, since it is an important topic, and I've read that  
> Smalltalks exception handling is very powerful, but I don't know  
> much about it and like to learn it.
> >
> > Kind Regards,
> >
> > Bart
> >
> > --
> > imagination is more important than knowledge - Albert Einstein
> > Logic will get you from A to B. Imagination will take you  
> everywhere - Albert Einstein
> > Learn from yesterday, live for today, hope for tomorrow. The  
> important thing is not to stop questioning. - Albert Einstein
> > The true sign of intelligence is not knowledge but imagination. -  
> Albert Einstein
> > Gravitation is not responsible for people falling in love. -  
> Albert Einstein
> > _______________________________________________
> > Pharo-project mailing list
> > [email protected]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
>
> -- 
> imagination is more important than knowledge - Albert Einstein
> Logic will get you from A to B. Imagination will take you everywhere  
> - Albert Einstein
> Learn from yesterday, live for today, hope for tomorrow. The  
> important thing is not to stop questioning. - Albert Einstein
> The true sign of intelligence is not knowledge but imagination. -  
> Albert Einstein
> Gravitation is not responsible for people falling in love. - Albert  
> Einstein
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

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






_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to