ExceptionHandlerSet.st
author Claus Gittinger <cg@exept.de>
Mon, 05 Feb 2018 00:40:49 +0100
changeset 22531 8675adc00fde
parent 20203 21227fea15dc
child 22712 aa91ca850dc0
permissions -rw-r--r--
#DOCUMENTATION by cg class: ExceptionHandlerSet category of: #on:do: class: ExceptionHandlerSet class comment/format in: #documentation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22531
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
     1
"{ Encoding: utf8 }"
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
     2
4466
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
     3
"
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
     4
 COPYRIGHT (c) 1999 by eXept Software AG
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
     5
              All Rights Reserved
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
     6
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
     7
 This software is furnished under a license and may be used
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
     8
 only in accordance with the terms of that license and with the
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    10
 be provided or otherwise made available to, or used by, any
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    11
 other person.  No title to or ownership of the software is
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    12
 hereby transferred.
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    13
"
6206
59d1ec1e1ed5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4546
diff changeset
    14
"{ Package: 'stx:libbasic' }"
59d1ec1e1ed5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4546
diff changeset
    15
19444
70d035d69cf1 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 15063
diff changeset
    16
"{ NameSpace: Smalltalk }"
70d035d69cf1 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 15063
diff changeset
    17
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    18
IdentityDictionary subclass:#ExceptionHandlerSet
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:''
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    22
	category:'Kernel-Exceptions'
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    23
!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    24
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    25
!ExceptionHandlerSet class methodsFor:'documentation'!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    26
4466
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    27
copyright
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    28
"
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    29
 COPYRIGHT (c) 1999 by eXept Software AG
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    30
              All Rights Reserved
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    31
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    32
 This software is furnished under a license and may be used
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    33
 only in accordance with the terms of that license and with the
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    35
 be provided or otherwise made available to, or used by, any
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    36
 other person.  No title to or ownership of the software is
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    37
 hereby transferred.
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    38
"
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    39
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    40
!
9cba6f4ecec4 copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents: 4464
diff changeset
    41
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    42
documentation
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    43
"
20203
21227fea15dc #OTHER by mawalch
mawalch
parents: 19444
diff changeset
    44
    An ExceptionHandlerSet allows a group of unrelated signals to be handled
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    45
    by individual handlers - their evaluation is equivalent to a corresponding
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    46
    number of nested signal handlers, but more efficient and
22531
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
    47
    somwehat easier to program and read.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    48
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    49
    [author:]
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    50
        Stefan Vogel
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    51
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    52
    [see also:]
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    53
        Exception Signal SignalSet
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    54
"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    55
!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    56
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    57
examples
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    58
"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    59
                                                                [exBegin]
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    60
         |h num|
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    61
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    62
         h := ExceptionHandlerSet new.
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    63
         h on:ZeroDivide
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    64
           do:[:ex | 'division by zero' printCR. ex proceed].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    65
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    66
         h on:HaltInterrupt
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    67
           do:[:ex | 'halt encountered ' printCR. ex proceed].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    68
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    69
         h on:DomainError
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    70
           do:[:ex | 'domain error  ' printCR. ex proceed].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    71
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    72
         h handleDo:[
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    73
            num := 0.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    74
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    75
            'now dividing' printCR.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    76
            1 // num.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    77
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    78
            'now doing bad arcSin' printCR.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    79
            num := 50.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    80
            num arcSin.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    81
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    82
            'now halting' printCR.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    83
            self halt.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    84
         ]
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    85
                                                                [exEnd]
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    86
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    87
                                                                [exBegin]
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    88
         |h num|
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    89
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    90
         h := ExceptionHandlerSet new.
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    91
         h on:ZeroDivide
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    92
           do:[:ex | 'division by zero' printCR. ex proceed].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    93
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    94
         h on:HaltInterrupt
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    95
           do:[:ex | 'halt encountered ' printCR. ex proceed].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    96
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    97
         h on:DomainError
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
    98
           do:[:ex | 'domain error ' printCR. ex proceed].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    99
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   100
         [
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   101
            num := 0.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   102
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
   103
            'now dividing' printCR.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   104
            1 // num.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   105
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
   106
            'now doing bad arcSin' printCR.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   107
            num := 50.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   108
            num arcSin.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   109
8290
520c27f8cae2 examples
Stefan Vogel <sv@exept.de>
parents: 8237
diff changeset
   110
            'now halting' printCR.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   111
            self halt.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   112
         ] valueWithExceptionHandler:h
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   113
                                                                [exEnd]
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   114
"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   115
! !
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   116
8478
100e53cacce4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8290
diff changeset
   117
!ExceptionHandlerSet methodsFor:'Compatibility-VW5.4'!
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   118
8478
100e53cacce4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8290
diff changeset
   119
on:aSignalOrException handle:aHandler
8237
afaad9c5cad2 Add #on:do: as synonym for #on:handle:
Stefan Vogel <sv@exept.de>
parents: 6629
diff changeset
   120
    "add a handler for aSignal to the set"
afaad9c5cad2 Add #on:do: as synonym for #on:handle:
Stefan Vogel <sv@exept.de>
parents: 6629
diff changeset
   121
8478
100e53cacce4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8290
diff changeset
   122
    self on:aSignalOrException do:aHandler
8237
afaad9c5cad2 Add #on:do: as synonym for #on:handle:
Stefan Vogel <sv@exept.de>
parents: 6629
diff changeset
   123
8478
100e53cacce4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8290
diff changeset
   124
    "Created: / 26.7.1999 / 09:51:37 / stefan"
100e53cacce4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8290
diff changeset
   125
! !
100e53cacce4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8290
diff changeset
   126
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   127
!ExceptionHandlerSet methodsFor:'queries'!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   128
8681
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   129
accepts:anExceptionHandler
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   130
    "return true, if the receiver accepts the argument, aSignal.
19444
70d035d69cf1 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 15063
diff changeset
   131
     (i.e. if any of the receiver's elements is aSignal or a parent of it)."
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   132
20203
21227fea15dc #OTHER by mawalch
mawalch
parents: 19444
diff changeset
   133
    self keysDo:[:eachExceptionHandler |
21227fea15dc #OTHER by mawalch
mawalch
parents: 19444
diff changeset
   134
        (eachExceptionHandler==anExceptionHandler
8681
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   135
         or:[eachExceptionHandler accepts:anExceptionHandler]) ifTrue:[^ true].
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   136
    ].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   137
    ^ false
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   138
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   139
    "Created: / 26.7.1999 / 09:53:09 / stefan"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   140
!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   141
8681
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   142
exceptionHandlerFor:anException in:aContext
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   143
    "answer the exceptionHandler for anException from aContext."
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   144
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   145
    ^ self
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   146
!
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   147
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   148
handlerForSignal:signal
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   149
    "answer the handler block for signal"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   150
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   151
    self keysAndValuesDo:[:sig :handler|
4513
Claus Gittinger <cg@exept.de>
parents: 4491
diff changeset
   152
        (sig == signal or:[sig accepts:signal]) ifTrue:[
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   153
            ^ handler.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   154
        ].
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   155
    ].
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   156
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   157
    ^ nil
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   158
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   159
    "Modified: / 26.7.1999 / 09:59:43 / stefan"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   160
    "Created: / 26.7.1999 / 11:29:29 / stefan"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   161
!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   162
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   163
handlerForSignal:signal context:theContext originator:originator
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   164
    "answer the handler block for the signal from originator.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   165
     The block is retrieved from aContext.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   166
     Answer nil if the signal is not handled"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   167
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   168
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   169
    (theContext selector ~~ #'handleDo:from:'
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   170
     or:[(theContext argAt:2) == originator]) ifTrue:[
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   171
        self keysAndValuesDo:[:sig :handler|
4513
Claus Gittinger <cg@exept.de>
parents: 4491
diff changeset
   172
            (sig == signal or:[sig accepts:signal]) ifTrue:[
11636
2a4feb56ca70 changed #handlerForSignal:context:originator:
Stefan Vogel <sv@exept.de>
parents: 8700
diff changeset
   173
                ^ handler ? [nil].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   174
            ].
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   175
        ].
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   176
    ].
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   177
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   178
    ^ nil
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   179
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   180
    "Created: / 26.7.1999 / 09:53:28 / stefan"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   181
    "Modified: / 26.7.1999 / 09:59:43 / stefan"
4473
793078981f01 added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents: 4466
diff changeset
   182
!
793078981f01 added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents: 4466
diff changeset
   183
4546
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   184
handlerProtectedBlock:doBlock inContext:context
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   185
    "set the handlerProtectedBlock in context"
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   186
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   187
    context argAt:1 put:doBlock.
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   188
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   189
    "
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   190
      |s|
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   191
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   192
      s := ExceptionHandlerSet new.
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   193
      s at:Error put:[:ex| ex restartDo:[55]].
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   194
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   195
      s handleDo:[1 // 0]
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   196
    "
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   197
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   198
!
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   199
8681
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   200
handles:anException
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   201
    "return true, if the receiver handles the argument, anException.
19444
70d035d69cf1 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 15063
diff changeset
   202
     (i.e. if any of the receiver's elements handles anException)."
4473
793078981f01 added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents: 4466
diff changeset
   203
20203
21227fea15dc #OTHER by mawalch
mawalch
parents: 19444
diff changeset
   204
    self keysDo:[:eachExceptionHandler|
8681
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   205
        (eachExceptionHandler handles:anException) ifTrue:[^ true]
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   206
    ].
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   207
    ^ false
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   208
! !
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   209
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   210
!ExceptionHandlerSet methodsFor:'save evaluation'!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   211
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   212
handleDo:aBlock
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   213
    "evaluate the argument, aBlock.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   214
     If any of the signals in the receiver is raised during evaluation,
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   215
     evaluate the handleBlock passing it an Exception argument.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   216
     The handler may decide how to react to the signal by sending
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   217
     a corresponding message to the exception (see there).
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   218
     If the signal is not raised, return the value of evaluating
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   219
     aBlock."
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   220
4546
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   221
    <context: #return>
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   222
    <exception: #handle>
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   223
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   224
    "/ thisContext markForHandle. -- same as above pragma
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   225
    ^ aBlock value  "the real logic is in Exception>>doRaise"
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   226
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   227
   "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   228
    |h num|
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   229
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   230
    h := ExceptionHandlerSet new.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   231
    h on:(Number divisionByZeroSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   232
      handle:[:ex | 'division by zero' printNL. ex proceed].
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   233
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   234
    h on:(Object haltSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   235
      handle:[:ex | 'halt encountered ' printNL. ex proceed].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   236
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   237
    h on:(Float domainErrorSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   238
      handle:[:ex | 'domain error  ' printNL. ex proceed].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   239
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   240
    h handleDo:[
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   241
       num := 0.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   242
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   243
       'now dividing' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   244
       1 // num.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   245
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   246
       'now doing bad arcSin' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   247
       num := 50.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   248
       num arcSin.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   249
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   250
       'now halting' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   251
       self halt.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   252
    ]
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   253
    "
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   254
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   255
    "Created: / 26.7.1999 / 09:56:44 / stefan"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   256
    "Modified: / 26.7.1999 / 11:01:53 / stefan"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   257
!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   258
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   259
handleDo:aBlock from:originator
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   260
    "evaluate the argument, aBlock.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   261
     If any of the signals in the receiver is raised during evaluation,
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   262
     evaluate the handleBlock passing it an Exception argument.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   263
     The handler may decide how to react to the signal by sending
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   264
     a corresponding message to the exception (see there).
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   265
     If the signal is not raised, return the value of evaluating
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   266
     aBlock."
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   267
4546
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   268
    <context: #return>
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   269
    <exception: #handle>
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   270
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   271
    "/ thisContext markForHandle. -- same as above pragma
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   272
    ^ aBlock value  "the real logic is in Exception>>doRaise"
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   273
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   274
   "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   275
    |h num|
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   276
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   277
    h := ExceptionHandlerSet new.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   278
    h on:(Number divisionByZeroSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   279
      handle:[:ex | 'division by zero' printNL. ex proceed].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   280
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   281
    h on:(Object haltSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   282
      handle:[:ex | 'halt encountered ' printNL. ex proceed].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   283
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   284
    h on:(Float domainErrorSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   285
      handle:[:ex | 'domain error  ' printNL. ex proceed].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   286
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   287
    h handleDo:[
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   288
       'now halting' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   289
       self halt.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   290
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   291
       'the following exceptions are not handled.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   292
        A debugger is opened' printNL.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   293
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   294
       'now dividing' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   295
       num := 0.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   296
       1 // num.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   297
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   298
       'now doing bad arcSin' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   299
       num := 50.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   300
       num arcSin.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   301
    ] from:self
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   302
    "
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   303
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   304
    "Created: / 26.7.1999 / 09:56:44 / stefan"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   305
    "Modified: / 26.7.1999 / 11:36:47 / stefan"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   306
! !
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   307
22531
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   308
!ExceptionHandlerSet methodsFor:'setup'!
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   309
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   310
on:anExceptionHandler do:aHandlerBlock
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   311
    "add a handler for aSignal to the set"
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   312
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   313
    anExceptionHandler isBehavior ifTrue:[
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   314
        "load class, if not yet loaded"
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   315
        anExceptionHandler autoload.
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   316
    ].
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   317
    anExceptionHandler isExceptionHandler ifFalse:[
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   318
        SignalError raiseWith:anExceptionHandler errorString:' - trying to add a non-exceptionHandler to a SignalSet'.
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   319
    ].
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   320
    self at:anExceptionHandler put:aHandlerBlock
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   321
! !
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   322
8700
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   323
!ExceptionHandlerSet methodsFor:'testing'!
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   324
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   325
isExceptionHandler
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   326
    "return true, if the receiver responds to the exception handler protocol,
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   327
     especially to the #accepts: and #handles: messages"
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   328
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   329
    ^ true
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   330
! !
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   331
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   332
!ExceptionHandlerSet class methodsFor:'documentation'!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   333
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   334
version
19444
70d035d69cf1 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 15063
diff changeset
   335
    ^ '$Header$'
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   336
! !
15063
5f491d49189d class: ExceptionHandlerSet
Stefan Vogel <sv@exept.de>
parents: 11636
diff changeset
   337