TryCatch

Simon Kirk Simon.Kirk at pinesoft.co.uk
Mon Nov 28 15:26:29 UTC 2005


Ah thanks Noury - I admit that I was confused about the order in which 
the calls should be made, now it makes more object-sense :)

Noury Bouraqadi wrote:

> Simon,
>
> Le 25 nov. 05, à 11:12, Simon Kirk a écrit :
>
>> I may be overstepping my bounds here as an almost complete Squeak
>> newb, but given you mentioned "try/catch" then you're probably
>> thinking "in Java" so you'll want to know about finally - which as 
>> far as I can tell is done by:
>>
>> [code]
>>     on: Exception
>>     do: [:ex | more code]
>>     ensure: [do this no matter what]
>>
>> (ie the ensure: [] is the same as a finally).
>>
> There is no #on:do:ensure: method. One have to send 2 messages :
> #ensure: and #on:do:
>
> [[code] ensure: [do this no matter what]]
>     on: Exception
>     do: [:ex| more code]
>
> Note : the "ensure block" is performed after the exception handling 
> (do block)
>
> Noury
>
>> Just my $0.02 - if I'm wrong somebody please correct me :)
>>
>> stéphane ducasse wrote:
>>
>>> Damien
>>>
>>> read the ExceptionTest classes they are gorgeous. Really This is 
>>> the  best documentation on exception catching
>>> I ever read... :)
>>>
>>> Stef
>>>
>>> On 24 nov. 05, at 20:49, Damien Cassou wrote:
>>>
>>>> Hi,
>>>>
>>>> How can I try/catch for errors in Squeak ? I didn't find anything.  
>>>> I would like to do something like :
>>>>
>>>> [ aPieceOfCodeThatCanThrowsExceptions ]
>>>>    catch: [:exception | Transcript show: exception]
>>>>
>>>> or
>>>>
>>>> self try: [ aPieceOfCodeThatCanThrowsExceptions ]
>>>>       catch: [:exception | Transcript show: exception]
>>>>
>>>>
>>>> thank you
>>>>
>>>>
>>>> -- 
>>>> Damien
>>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>> This message has been scanned for viruses by BlackSpider MailControl 
>> - www.blackspider.com
>>
>>
>>
> --------------------------------------------------------------
> Dr. Noury Bouraqadi - Enseignant/Chercheur
> Ecole des Mines de Douai - Dept. G.I.P
> http://csl.ensm-douai.fr/noury
>
> European Smalltalk Users Group Board
> http://www.esug.org
>
> Squeak: an Open Source Smalltalk
> http://www.squeak.org
> --------------------------------------------------------------
>
>
>
>
>



More information about the Squeak-dev mailing list