eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HandlerCollection':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: HandlerCollection


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--OrderedCollection
            |
            +--HandlerCollection

Package:
stx:libbasic2
Category:
Kernel-Exceptions
Version:
rev: 1.6 date: 2021/01/20 14:33:02
user: cg
file: HandlerCollection.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


A HandlerCollection allows a group of unrelated signals to be handled
by individual handlers - their evaluation is equivalent to a corresponding
number of nested signal handlers, but somwehat easier to program.
In the real world, handlerCollections are seldom needed and actually currently
not used by the system.

copyright

COPYRIGHT (c) 1994 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Instance protocol:

adding
o  on: aSignal handle: aHandler
add a signal<->handler pair to the receiver collection

private
o  from: start to: stop handleDo: aBlock
this method recursively sets up a bunch of nested
handlers, and finally evaluates the argument, aBlock

save evaluation
o  handleDo: aBlock
evaluate the argument, aBlock.
If any of the signals in the receiver is raised during evaluation,
evaluate the corresponding handleBlock from the receiver,
passing it an Exception argument.
The handler may decide how to react to the signal by sending
a corresponding message to the exception (see there).
If none of the signals is raised during evaluation, return the
value returned by aBlock.

Usage example(s):

     |h num|

     h := HandlerCollection new.
     h on:(Number divisionByZeroSignal)
       handle:[:ex | 'division by zero' printNL. ex proceed].

     h on:(Object haltSignal)
       handle:[:ex | 'halt encountered ' printNL. ex proceed].

     h on:(Float domainErrorSignal)
       handle:[:ex | 'domain error  ' printNL. ex proceed].

     h handleDo:[
	num := 0.

	'now dividing' printNL.
	1 // num.

	'now doing bad arcSin' printNL.
	num := 50.
	num arcSin.

	'now halting' printNL.
	self halt.
     ]



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sun, 22 Dec 2024 08:53:00 GMT