On Tue, Nov 1, 2011 at 1:35 AM, Jeff Gray <jeff@rogerthedog.com> wrote:
I have just watched James Robertson's Exception screencast on exceptions in
Pharo.
I haven't really bothered with it previously as I have only played around
and haven't done anything in anger.
My commercial background in Java and C# has been with quite different styles
of exception handling.
Java was always cluttered with exception handling and re-throwing all
through the code whereas in .net it was very much a 'let it bubble up to the
container' approach.

Although James screencast shows the mechanics of exceptions I'm wondering
what is a normal exception handling strategy in Pharo?

Imagine that in Pharo they would all be "runtime" exception (non-checked was called in Java? I don't remember)... well, that means that the "throws" is not part of the signature and hence a caller doesn't HAVE to mandatory handle the exception.� To handle an exception you can do:

[� Transcript show: 'this is the code that I want to execute and may trhow an aexception'� ]
on: ThisParticularError
do: [ self manageThisParticularError ]

You can handle Error if you want something more general. You can send #resume to an exception (if possible), etc, etc ec.
As Stef said, read the chapter and ask if you have further questions: https://gforge.inria.fr/frs/download.php/26600/PBE2-Exceptions-2010-03-02.pdf

Obvoiusly tutorial code doesn't want to get bogged down with exceptions when
trying to teach a specific aspect in smalltalk/pharo/oo etc but I'm yet to
see tutorial example code that handles exceptions.


--
View this message in context: http://forum.world.st/Exception-style-tp3962162p3962162.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
Mariano
http://marianopeck.wordpress.com