[Newbies] How to create new exception

Matthew Fulmer tapplek at gmail.com
Sun Oct 12 16:20:00 UTC 2008


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]

-- 
Matthew Fulmer -- http://mtfulmer.wordpress.com/


More information about the Beginners mailing list