Thanks a lot for all the information. 1 more question, after create a new exception class then to use it let's say I have to define something like: Then use it:
[SpontaneousCombustionException signal] on: SpontaneousCombustionException do: [:ex | Transcript show: 'Explosion detected'; cr]
My question is where do I write this code? Is it in one of my method for example I create spontaneousCombustionSignal method, and I write this code there?
"Alex" == Alex Chi alex_chi99@yahoo.com writes:
Alex> Can you give me an example on how to create new exception and call/use Alex> that exception in my program? I try to googling but don't seem to find Alex> one. Thanks. ------------------------------
Message: 4 Date: Sun, 12 Oct 2008 09:20:00 -0700 From: Matthew Fulmer tapplek@gmail.com Subject: Re: [Newbies] How to create new exception To: beginners@lists.squeakfoundation.org Message-ID: 20081012162000.GG5308@tacobell Content-Type: text/plain; charset=us-ascii
On Sun, Oct 12, 2008 at 01:50:05AM -0700, Alex Chi wrote:
Can you give me an example on how to create new exception and call/use that exception in my program? I try to googling but don't seem to find one. Thanks.
Create an exception class:
Exception subclass: #SpontaneousCombustionException instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Heat'.
Then use it:
[SpontaneousCombustionException signal] on: SpontaneousCombustionException do: [:ex | Transcript show: 'Explosion detected'; cr]
"Alex" == Alex Chi alex_chi99@yahoo.com writes:
Alex> Thanks a lot for all the information. Alex> 1 more question, after create a new exception class then to use it let's say I have to define something like: Alex> Then use it:
Alex> [SpontaneousCombustionException signal] Alex> on: SpontaneousCombustionException Alex> do: [:ex | Transcript show: 'Explosion detected'; cr]
No, you write:
[some code. that might. explode here: youKnow. andMore stuff. ] on: SpontaneousCombustionException do: [:ex | Transcript show: 'Explosion detected'; cr].
And then if any of the code you call in that first block throws a SpontaneousCombustionException, you get into your second block.
beginners@lists.squeakfoundation.org