ExceptionHandlerSet.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 20:55:17 +0200
changeset 24417 03b083548da2
parent 23305 daf30c8d685b
child 24734 008f54b2eb48
permissions -rw-r--r--
#REFACTORING by exept class: Smalltalk class changed: #recursiveInstallAutoloadedClassesFrom:rememberIn:maxLevels:noAutoload:packageTop:showSplashInLevels: Transcript showCR:(... bindWith:...) -> Transcript showCR:... with:...
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
23305
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   129
accepts:aSignalOrExceptionClass
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 |
23305
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   134
        (eachExceptionHandler == aSignalOrExceptionClass
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   135
         or:[eachExceptionHandler accepts:aSignalOrExceptionClass]) ifTrue:[^ true].
8681
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
23305
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   139
    "Created: / 26-07-1999 / 09:53:09 / stefan"
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   140
    "Modified (format): / 28-08-2018 / 11:28:00 / Claus Gittinger"
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   141
!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   142
8681
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   143
exceptionHandlerFor:anException in:aContext
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   144
    "answer the exceptionHandler for anException from aContext."
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   145
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   146
    ^ self
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   147
!
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   148
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   149
handlerForSignal:signal
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   150
    "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
   151
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   152
    self keysAndValuesDo:[:sig :handler|
4513
Claus Gittinger <cg@exept.de>
parents: 4491
diff changeset
   153
        (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
   154
            ^ handler.
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
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   158
    ^ nil
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   159
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   160
    "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
   161
    "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
   162
!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   163
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   164
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
   165
    "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
   166
     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
   167
     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
   168
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   169
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   170
    (theContext selector ~~ #'handleDo:from:'
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   171
     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
   172
        self keysAndValuesDo:[:sig :handler|
4513
Claus Gittinger <cg@exept.de>
parents: 4491
diff changeset
   173
            (sig == signal or:[sig accepts:signal]) ifTrue:[
11636
2a4feb56ca70 changed #handlerForSignal:context:originator:
Stefan Vogel <sv@exept.de>
parents: 8700
diff changeset
   174
                ^ handler ? [nil].
4464
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
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   179
    ^ nil
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   180
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   181
    "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
   182
    "Modified: / 26.7.1999 / 09:59:43 / stefan"
4473
793078981f01 added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents: 4466
diff changeset
   183
!
793078981f01 added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents: 4466
diff changeset
   184
4546
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   185
handlerProtectedBlock:doBlock inContext:context
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   186
    "set the handlerProtectedBlock in context"
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   187
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   188
    context argAt:1 put:doBlock.
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
    "
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   191
      |s|
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   192
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   193
      s := ExceptionHandlerSet new.
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   194
      s at:Error put:[:ex| ex restartDo:[55]].
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   195
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   196
      s handleDo:[1 // 0]
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
!
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   200
8681
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   201
handles:anException
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 8589
diff changeset
   202
    "return true, if the receiver handles the argument, anException.
19444
70d035d69cf1 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 15063
diff changeset
   203
     (i.e. if any of the receiver's elements handles anException)."
4473
793078981f01 added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents: 4466
diff changeset
   204
23305
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   205
    ^ self accepts:(anException creator).
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   206
    
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   207
"/    self keysDo:[:eachExceptionHandler|
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   208
"/        (eachExceptionHandler handles:anException) ifTrue:[^ true]
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   209
"/    ].
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   210
"/    ^ false
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   211
daf30c8d685b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22712
diff changeset
   212
    "Modified: / 28-08-2018 / 11:28:30 / Claus Gittinger"
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   213
! !
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   214
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   215
!ExceptionHandlerSet methodsFor:'save evaluation'!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   216
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   217
handleDo:aBlock
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   218
    "evaluate the argument, aBlock.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   219
     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
   220
     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
   221
     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
   222
     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
   223
     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
   224
     aBlock."
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   225
4546
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   226
    <context: #return>
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   227
    <exception: #handle>
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   228
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   229
    "/ thisContext markForHandle. -- same as above pragma
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   230
    ^ 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
   231
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   232
   "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   233
    |h num|
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   234
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   235
    h := ExceptionHandlerSet new.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   236
    h on:(Number divisionByZeroSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   237
      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
   238
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   239
    h on:(Object haltSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   240
      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
   241
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   242
    h on:(Float domainErrorSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   243
      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
   244
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   245
    h handleDo:[
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   246
       num := 0.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   247
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   248
       'now dividing' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   249
       1 // num.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   250
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   251
       'now doing bad arcSin' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   252
       num := 50.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   253
       num arcSin.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   254
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   255
       'now halting' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   256
       self halt.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   257
    ]
4464
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
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   260
    "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
   261
    "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
   262
!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   263
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   264
handleDo:aBlock from:originator
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   265
    "evaluate the argument, aBlock.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   266
     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
   267
     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
   268
     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
   269
     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
   270
     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
   271
     aBlock."
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   272
4546
ecd03e12cce3 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   273
    <context: #return>
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   274
    <exception: #handle>
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   275
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   276
    "/ thisContext markForHandle. -- same as above pragma
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   277
    ^ 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
   278
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   279
   "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   280
    |h num|
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   281
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   282
    h := ExceptionHandlerSet new.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   283
    h on:(Number divisionByZeroSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   284
      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
   285
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   286
    h on:(Object haltSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   287
      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
   288
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   289
    h on:(Float domainErrorSignal)
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   290
      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
   291
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   292
    h handleDo:[
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   293
       'now halting' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   294
       self halt.
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   295
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   296
       'the following exceptions are not handled.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   297
        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
   298
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   299
       'now dividing' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   300
       num := 0.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   301
       1 // num.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   302
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   303
       'now doing bad arcSin' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   304
       num := 50.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   305
       num arcSin.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   306
    ] from:self
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   307
    "
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   308
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   309
    "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
   310
    "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
   311
! !
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   312
22531
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   313
!ExceptionHandlerSet methodsFor:'setup'!
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   314
22712
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   315
on:anExceptionHandlerOrHandlerCollection do:aHandlerBlock
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   316
    "add a handler for aSignal to the set.
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   317
     anExceptionHandlerOrHandlerCollection may be a single exceptionHandler or
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   318
     a Collection of exceptionHandlers (e.g. Array or SignalSet)"
22531
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   319
22712
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   320
    anExceptionHandlerOrHandlerCollection asCollectionDo:[:eachHandler|
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   321
        eachHandler isBehavior ifTrue:[
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   322
            "load class, if not yet loaded"
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   323
            eachHandler autoload.
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   324
        ].
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   325
        eachHandler isExceptionHandler ifFalse:[
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   326
            SignalError raiseWith:eachHandler errorString:' - trying to add a non-exceptionHandler to a SignalSet'.
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   327
        ].
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   328
        self at:eachHandler put:aHandlerBlock.
22531
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   329
    ].
22712
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   330
aa91ca850dc0 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22531
diff changeset
   331
    "Modified (comment): / 26-04-2018 / 14:23:45 / stefan"
22531
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   332
! !
8675adc00fde #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20203
diff changeset
   333
8700
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   334
!ExceptionHandlerSet methodsFor:'testing'!
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   335
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   336
isExceptionHandler
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   337
    "return true, if the receiver responds to the exception handler protocol,
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   338
     especially to the #accepts: and #handles: messages"
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   339
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   340
    ^ true
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   341
! !
c416a3fb7e2f comments/category
Stefan Vogel <sv@exept.de>
parents: 8681
diff changeset
   342
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   343
!ExceptionHandlerSet class methodsFor:'documentation'!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   344
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   345
version
19444
70d035d69cf1 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 15063
diff changeset
   346
    ^ '$Header$'
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   347
! !
15063
5f491d49189d class: ExceptionHandlerSet
Stefan Vogel <sv@exept.de>
parents: 11636
diff changeset
   348