[Newbies] How to create new exception

Randal L. Schwartz merlyn at stonehenge.com
Mon Oct 13 19:41:49 UTC 2008


>>>>> "Alex" == Alex Chi <alex_chi99 at 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.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


More information about the Beginners mailing list