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? 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. |
Hi jeff
It depends. What I saw in the software developed by Hernan wilkinson to manage conferences (Patagonia) is that hernan defines a lot of specific exceptions. In Core pharo we are a bit learning and cleaning the menu pop up to indicate error. It should be an error and trapped by the UI manager. I guess that experts will react on your questions. Now I do not know if you know the exceptions chapter http://www.pharobyexample.org/ Stef On Nov 1, 2011, at 1:35 AM, Jeff Gray 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? > 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. > |
In reply to this post by Jeff Gray
On Tue, Nov 1, 2011 at 1:35 AM, Jeff Gray <[hidden email]> wrote: I have just watched James Robertson's Exception screencast on exceptions in 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 -- Mariano http://marianopeck.wordpress.com |
Free forum by Nabble | Edit this page |