Signal.st
author Claus Gittinger <cg@exept.de>
Mon, 23 Aug 1999 13:57:28 +0200
changeset 4622 905b21c17057
parent 4564 5401b0d1a6e3
child 4676 5d469e2da40a
permissions -rw-r--r--
care for non-class nameClass in printOn:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
4502
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
     3
              All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
Object subclass:#Signal
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4563
diff changeset
    14
	instanceVariableNames:'mayProceed notifierString nameClass message handlerBlock parent'
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4563
diff changeset
    15
	classVariableNames:''
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4563
diff changeset
    16
	poolDictionaries:''
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4563
diff changeset
    17
	category:'Kernel-Exceptions'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
2207
ee6d4213b9df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1610
diff changeset
    20
!Signal class methodsFor:'documentation'!
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    21
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    22
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    23
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    24
 COPYRIGHT (c) 1993 by Claus Gittinger
4502
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
    25
              All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    26
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    27
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    28
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    30
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    31
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    32
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    33
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    34
!
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    35
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    36
documentation
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    37
"
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    38
    Signal and Exception provide a framework for exception handling.
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    39
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    40
    A Signal object is usually defined somewhere up in the calling chain
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    41
    and associated with some abnormal event. Many signals are also
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    42
    created at startup time and reused.
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    43
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    44
    When the event is raised (by Signal>>raise) the control will be either 
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    45
    given to a debugger or - if a handler was defined - to the handler. 
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    46
    The handler will get a description of what (and where) happened in an 
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    47
    Exception object and can decide how to react on the situation (i.e. 
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    48
    proceed, return or restart).
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    49
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    50
    There is also a companion class called SignalSet, which allows handling
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    51
    multiple signals with one handler (for example all arithmetic signals).
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    52
    And, finally there is a very special SignalSet which allows catching
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    53
    any signal (SignalSet>>anySignal).
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    54
171
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    55
    Since there is no official documentation on signal handling (i.e. none
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    56
    of the books describes it), this Signal implementation has been modeled
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    57
    after what some PD programs seem to expect and what alpha/beta testers told
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    58
    me it should look like.
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    59
    It may not be perfect and undergo minor changes.
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    60
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    61
    special:
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    62
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    63
    In addition to the nested catch & throw mechanism, signals can also be
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    64
    used when no such handler scope exists. To support this, signals can be 
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    65
    assigned a handlerBlock, which gets evaluated with the exception as argument 
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    66
    in case no handler was found (on the stack).
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    67
171
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    68
    If no handler was found (i.e. neither a handler context on the stack, nor
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    69
    a static handler block), the NoHandlerSignal will be raised instead,
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    70
    passing it the original exception in its exception-parameter.
171
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    71
    This NoHandlerSignal can be handled just like any other signal.
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    72
    (therefore, it is possible to catch any error by catching NoHandlerSignal.
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    73
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    74
    When the NoHandler signal is raised, and neither a handler-context, nor 
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    75
    a handler block is defined for it, an emergencyHandler(-block) is evaluated.
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    76
    This block is either provided by the current process 
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    77
    (see Process>>emergencySignalHandler) or as a global default by the Exception
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    78
    class (see Exception>>emergencyHandler).
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    79
    The default emergencyHandlerBlock (from Exception) will bring up a debugger.
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    80
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    81
    HandlerBlocks allow a global (if its the EmergencyHandler in Exception)
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    82
    or per-process signal handling to be added. Even to code which was never
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    83
    planned to handle signals.
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    84
171
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    85
    See samples in 'doc/coding' and actual raise code in Exception.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    86
1275
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    87
    [Instance variables:]
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    88
4502
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
    89
        mayProceed      <Boolean>       hint for the debugger - program may 
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
    90
                                        proceed (currently not honored by the
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
    91
                                        debugger)
1275
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    92
4502
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
    93
        notifierString  <String>        error message to be output 
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    94
4502
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
    95
        nameClass       <Class>         for the printOn-implementation; nameClass
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
    96
                                        is the class, to which message (below) 
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
    97
                                        should be sent to create the receiver.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    98
4502
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
    99
        message         <Symbol>        for the printOn-implementation; message
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   100
                                        is the selector, which should be sent to 
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   101
                                        nameClass (above) to create the receiver.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   102
4502
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   103
        handlerBlock    <Block>         if nonNil, a 1-arg block to be 
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   104
                                        evaluated when no handler context is 
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   105
                                        found. The block gets the exception
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   106
                                        object as argument. This will play the role
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   107
                                        of an on-stack handler.
1275
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   108
1292
89497fff7f87 documentation
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   109
    [author:]
4502
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   110
        Claus Gittinger
1292
89497fff7f87 documentation
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   111
1275
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   112
    [see also:]
4554
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4553
diff changeset
   113
        GenericException 
4502
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   114
        SignalSet QuerySignal
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   115
        Object
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   116
        (``Exception handling and signals'': programming/exceptions.html)
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   117
"
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   118
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   119
2207
ee6d4213b9df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1610
diff changeset
   120
!Signal class methodsFor:'instance creation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   121
a27a279701f8 Initial revision
claus
parents:
diff changeset
   122
new
a27a279701f8 Initial revision
claus
parents:
diff changeset
   123
    "return a new signal"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   124
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   125
    ^ (self basicNew) notifierString:'signal'; mayProceed:true
3004
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   126
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   127
    "
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   128
     Signal new
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   129
    "
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   130
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   131
    "Modified: 8.10.1997 / 11:51:39 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   132
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   133
2207
ee6d4213b9df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1610
diff changeset
   134
!Signal class methodsFor:'Signal constants'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   135
3004
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   136
genericSignal
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   137
    "return the generic signal - thats the parent of all signals
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   138
     in the system."
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   139
4518
4716c8d7cb4c Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   140
    ^ GenericException
3004
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   141
4518
4716c8d7cb4c Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   142
    "Created: / 8.10.1997 / 11:46:28 / cg"
4716c8d7cb4c Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   143
    "Modified: / 8.10.1997 / 11:47:08 / cg"
4716c8d7cb4c Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   144
    "Modified: / 4.8.1999 / 08:54:33 / stefan"
3004
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   145
!
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   146
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   147
noHandlerSignal
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   148
    "return the signal used to handle unhandled signals"
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   149
4527
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4518
diff changeset
   150
    ^ NoHandlerError
4518
4716c8d7cb4c Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   151
4716c8d7cb4c Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   152
    "Modified: / 4.8.1999 / 08:10:09 / stefan"
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   153
!
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   154
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   155
proceedErrorSignal
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   156
    "return the signal used to indicate that a handler tried to
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   157
     proceed a signal marked as nonproceedable.
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   158
     The parameter for the exception raised by this signal is
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   159
     the exception which tried to proceed."
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   160
4527
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4518
diff changeset
   161
    ^ ProceedError
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   162
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   163
    "Created: / 27.2.1998 / 14:36:15 / stefan"
4518
4716c8d7cb4c Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   164
    "Modified: / 4.8.1999 / 08:00:20 / stefan"
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   165
!
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   166
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   167
wrongProceedabilitySignal
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   168
    "return the signal used to indicate that a signaler wants
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   169
     to raise a nonproceedable signal proceedable.
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   170
     The parameter for the exception raised by this signal is
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   171
     the unproceedable signal."
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   172
4527
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4518
diff changeset
   173
    ^ WrongProceedabilityError
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   174
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   175
    "Created: / 27.2.1998 / 14:24:19 / stefan"
4518
4716c8d7cb4c Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   176
    "Modified: / 4.8.1999 / 08:03:46 / stefan"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   177
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   178
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   179
!Signal methodsFor:'accessing'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   180
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   181
errorString
4563
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   182
    "#errorString is deprecated, use description instead"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   183
4563
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   184
    ^ self description
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   185
!
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   186
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   187
handlerBlock
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   188
    "return the handlerblock - if non-nil, this will be evaluated with the exception 
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   189
     object as argument, if no #handle:do: context was found on the stack."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   190
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   191
    ^ handlerBlock
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   192
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   193
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   194
handlerBlock:aOneArgBlock
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   195
    "set the handlerblock - this will be evaluated with the exception 
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   196
     object as argument, if no #handle:do: context was found on the stack."
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   197
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   198
    handlerBlock := aOneArgBlock
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   199
!
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   200
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   201
mayProceed
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   202
    "return the signals ability to proceed.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   203
     This flag is (currently) not checked by the system;
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   204
     be prepared for changes here, to eventually have nonProceedable
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   205
     signals refuse to let you continue execution."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   206
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   207
    ^ mayProceed
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   208
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   209
a27a279701f8 Initial revision
claus
parents:
diff changeset
   210
mayProceed:aBoolean
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   211
    "set/clear the signals ability to proceed.
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   212
     This flag is (currently) not checked by the system;
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   213
     be prepared for changes here, to eventually have nonProceedable
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   214
     signals refuse to let you continue execution."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   215
a27a279701f8 Initial revision
claus
parents:
diff changeset
   216
    mayProceed := aBoolean
a27a279701f8 Initial revision
claus
parents:
diff changeset
   217
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   218
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   219
nameClass:aClass message:aSelector
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   220
    "this sets the class & selector of a method which returns
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   221
     that signal - this is simply for documentation purposes -
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   222
     see Signal>>printOn: implementation.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   223
     (took me a while to find that one out ;-)"
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   224
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   225
    nameClass := aClass.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   226
    message := aSelector
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   227
!
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   228
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   229
notifierString
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   230
    "return the notifier string"
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   231
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   232
    ^ notifierString
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   233
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   234
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   235
notifierString:aString
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   236
    "set the notifier string"
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   237
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   238
    notifierString := aString
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   239
!
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   240
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   241
parent
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   242
    "return the parent-signal of the receiver"
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   243
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   244
    ^ parent
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   245
!
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   246
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   247
parent:aSignal 
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   248
    "set the parent-signal of the receiver."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   249
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   250
    parent := aSignal
3004
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   251
!
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   252
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   253
parent:aSignal mayProceed:aBoolean
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   254
    "set the parent-signal and the mayProceed flag of the receiver."
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   255
3010
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
   256
    parent := aSignal.
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
   257
    mayProceed := aBoolean.
3004
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   258
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   259
    "Modified: 8.10.1997 / 11:56:11 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   260
! !
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   261
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   262
!Signal methodsFor:'copying'!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   263
3348
37b0481be091 must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents: 3280
diff changeset
   264
deepCopyUsing:aDictionary
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   265
    "raise an error - deepCopy is not allowed for signals"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   266
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   267
    ^ self deepCopyError
3348
37b0481be091 must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents: 3280
diff changeset
   268
37b0481be091 must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents: 3280
diff changeset
   269
    "Created: / 31.3.1998 / 15:43:01 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   270
! !
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   271
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   272
!Signal methodsFor:'instance creation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   273
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   274
newSignal
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   275
    "create a new signal, using the receiver as a prototype and
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   276
     setting the parent of the new signal to the receiver."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   277
3010
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
   278
    ^ (self copy) parent:self
3004
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   279
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   280
    "Modified: 8.10.1997 / 11:53:06 / cg"
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
   281
!
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
   282
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   283
newSignalMayProceed:aBoolean
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   284
    "create a new signal, using the receiver as a prototype and
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   285
     setting the parent of the new signal to the receiver."
362
claus
parents: 345
diff changeset
   286
3010
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
   287
    ^ (self copy) parent:self mayProceed:aBoolean
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
   288
3004
220af5090ec2 added the genericSignal for PP compatiblity
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   289
    "Modified: 8.10.1997 / 11:57:13 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   290
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   291
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   292
!Signal methodsFor:'printing'!
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   293
4563
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   294
description
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   295
    "return the notifier string.
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   296
     If the notifier string starts with space, prepend
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   297
     the parents notifier string"
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   298
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   299
    notifierString isNil ifTrue:[
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   300
        ^ parent errorString
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   301
    ] ifFalse:[
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   302
        (notifierString startsWith:Character space) ifTrue:[
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   303
            ^ parent description, notifierString
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   304
        ] ifFalse:[
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   305
            ^ notifierString
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   306
        ].
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   307
    ]
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   308
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   309
    "
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   310
      Object errorSignal description
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   311
    "
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   312
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   313
    "Modified: / 12.3.1998 / 15:04:41 / stefan"
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   314
!
a436888f8514 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
   315
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   316
printOn:aStream
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   317
    "append a printed representation of the receiver on aStream"
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   318
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   319
    nameClass notNil ifTrue:[
4622
905b21c17057 care for non-class nameClass in printOn:
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   320
        nameClass isBehavior ifTrue:[
905b21c17057 care for non-class nameClass in printOn:
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   321
            aStream nextPutAll:nameClass name.
905b21c17057 care for non-class nameClass in printOn:
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   322
        ] ifFalse:[
905b21c17057 care for non-class nameClass in printOn:
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   323
            nameClass printOn:aStream.
905b21c17057 care for non-class nameClass in printOn:
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   324
        ].
4502
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   325
        aStream space.
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   326
        aStream nextPutAll:message.
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   327
        ^ self
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   328
    ].
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   329
    ^ super printOn:aStream
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   330
! !
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   331
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   332
!Signal methodsFor:'queries'!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   333
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   334
accepts:aSignal
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   335
    "return true, if the receiver accepts the argument, aSignal.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   336
     (i.e. the receiver is aSignal or a parent of it). False otherwise."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   337
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   338
    |s|
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   339
4527
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4518
diff changeset
   340
    self == aSignal ifTrue:[^ true].
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   341
    aSignal isQuerySignal ifTrue:[^ false].
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   342
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   343
    s := aSignal.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   344
    [s notNil] whileTrue:[
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   345
        self == s ifTrue:[^ true].
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   346
        s := s parent
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   347
    ].
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   348
    ^ false
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   349
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   350
    "Modified: / 22.3.1999 / 12:45:42 / stefan"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   351
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   352
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   353
handlerForSignal:signal context:theContext originator:originator
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   354
    "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: 4440
diff changeset
   355
     The block is retrieved from aContext.
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   356
     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: 4440
diff changeset
   357
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   358
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   359
    (theContext selector ~~ #'handle:from:do:'
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   360
     or:[(theContext argAt:2) == originator]) ifTrue:[
4513
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   361
        (self == signal or:[self accepts:signal]) ifTrue:[
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   362
            ^ theContext argAt:1
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   363
        ]
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   364
    ].
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   365
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   366
    ^ nil
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   367
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   368
    "Created: / 25.7.1999 / 19:55:43 / stefan"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   369
!
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   370
4547
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   371
handlerProtectedBlock:doBlock inContext:context
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   372
    "set the handlerProtectedBlock in context"
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   373
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   374
    context selector == #handle:do: ifTrue:[
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   375
        context argAt:2 put:doBlock.
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   376
    ] ifFalse:[context selector == #handle:from:do: ifTrue:[
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   377
        context argAt:3 put:doBlock.
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   378
    ]].
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   379
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   380
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   381
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   382
!
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   383
4476
696ac99f2a52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4473
diff changeset
   384
handlingExceptionInContext:theContext
4473
793078981f01 added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents: 4466
diff changeset
   385
    "answer the handling signal from aContext."
793078981f01 added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents: 4466
diff changeset
   386
793078981f01 added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents: 4466
diff changeset
   387
    ^ self
793078981f01 added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents: 4466
diff changeset
   388
!
793078981f01 added #handlingSignalInContext:
Claus Gittinger <cg@exept.de>
parents: 4466
diff changeset
   389
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   390
inheritsFrom:anotherSignal
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   391
    "return true, if the receiver is a child of anotherSignal
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   392
     (i.e. if handling anotherSignal also handles the receiver)
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   393
     This is almost the same as accepts, but returns false, if
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   394
     the receiver is identical to anotherSignal."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   395
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   396
    self == anotherSignal ifTrue:[^ false].
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   397
    ^ anotherSignal accepts:self
3521
4d83701cfc28 care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   398
4d83701cfc28 care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   399
    "Modified: / 6.6.1998 / 20:37:47 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   400
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   401
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   402
isHandled
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   403
    "return true, if there is a handler for the receiver signal.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   404
     Raising an unhandled signal will usually lead into the debugger,
2689
ada9b102abcf typo fix
Claus Gittinger <cg@exept.de>
parents: 2497
diff changeset
   405
     but can be caught globally by setting Exceptions EmergencyHandler."
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   406
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   407
    ^ self isHandledIn:(thisContext sender).
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   408
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   409
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   410
isHandledIn:aContext
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   411
    "return true, if there is a handler for the receiver signal in the 
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   412
     contextChain starting with aContext."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   413
3521
4d83701cfc28 care for nil receiver in #isHandledIn:
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   414
    |con r|
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   415
4493
f5f8400d0219 tined #isHandledIn:
Claus Gittinger <cg@exept.de>
parents: 4491
diff changeset
   416
    con := Context findFirstSpecialHandle:true raise:false.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   417
    [con notNil] whileTrue:[
4493
f5f8400d0219 tined #isHandledIn:
Claus Gittinger <cg@exept.de>
parents: 4491
diff changeset
   418
        ((r := con receiver) notNil
f5f8400d0219 tined #isHandledIn:
Claus Gittinger <cg@exept.de>
parents: 4491
diff changeset
   419
         and:[(r handlerForSignal:self context:con originator:nil) notNil]
f5f8400d0219 tined #isHandledIn:
Claus Gittinger <cg@exept.de>
parents: 4491
diff changeset
   420
        ) ifTrue:[
f5f8400d0219 tined #isHandledIn:
Claus Gittinger <cg@exept.de>
parents: 4491
diff changeset
   421
            "found a handler context"
f5f8400d0219 tined #isHandledIn:
Claus Gittinger <cg@exept.de>
parents: 4491
diff changeset
   422
            ^ true
f5f8400d0219 tined #isHandledIn:
Claus Gittinger <cg@exept.de>
parents: 4491
diff changeset
   423
        ].
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   424
        con := con findSpecialHandle:true raise:false.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   425
    ].
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   426
    ^ false
2207
ee6d4213b9df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1610
diff changeset
   427
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   428
    "Created: / 23.7.1999 / 14:03:34 / stefan"
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   429
    "Modified: / 26.7.1999 / 15:24:34 / stefan"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   430
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   431
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   432
isQuerySignal
1249
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   433
    "return true, if this is a querySignal - always return false here"
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   434
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   435
    ^ false
1249
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   436
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   437
    "Modified: 22.4.1996 / 13:45:06 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   438
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   439
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   440
isSignal
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   441
    "return true, if the receiver is some kind of signal;
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   442
     true returned here - the method is redefined from Object."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   443
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   444
    ^ true
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   445
! !
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   446
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   447
!Signal methodsFor:'raising'!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   448
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   449
newException
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   450
    "answer a new exception object for this signal.
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   451
     Subclasses may redefine this method"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   452
4440
88843a1c2700 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 4438
diff changeset
   453
    ^ Exception signal:self originator:nil
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   454
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   455
    "Created: / 26.2.1998 / 19:53:56 / stefan"
4440
88843a1c2700 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 4438
diff changeset
   456
    "Modified: / 23.7.1999 / 13:41:00 / stefan"
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   457
!
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   458
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   459
newExceptionFrom:originator
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   460
    "answer a new exception object for this signal.
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   461
     Set the originator.
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   462
     Subclasses may redefine this method"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   463
4440
88843a1c2700 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 4438
diff changeset
   464
    ^ Exception signal:self originator:originator
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   465
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   466
    "Created: / 27.2.1998 / 09:17:00 / stefan"
4440
88843a1c2700 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 4438
diff changeset
   467
    "Modified: / 23.7.1999 / 13:41:15 / stefan"
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   468
!
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   469
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   470
raise
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   471
    "raise a signal nonproceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   472
     The signals notifierString is used as errorString."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   473
4555
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   474
    <context: #return>
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   475
4540
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   476
    ^ self newException 
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   477
        suspendedContext:thisContext sender;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   478
        raise
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   479
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   480
    "Modified: / 2.5.1996 / 16:36:23 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   481
    "Modified: / 5.3.1998 / 16:44:36 / stefan"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   482
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   483
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   484
raiseErrorString:aString
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   485
    "raise a signal nonproceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   486
     The argument is used as errorString."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   487
4555
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   488
    <context: #return>
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   489
4540
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   490
    ^ self newException 
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   491
        suspendedContext:thisContext sender;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   492
        errorString:aString;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   493
        raise.
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   494
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   495
    "Modified: / 9.5.1996 / 15:17:59 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   496
    "Modified: / 12.3.1998 / 15:15:22 / stefan"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   497
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   498
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   499
raiseFrom:something
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   500
    "raise a signal nonproceedable.
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   501
     The argument, something is passed both as parameter and originator."
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   502
4555
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   503
    <context: #return>
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   504
4540
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   505
    ^ (self newExceptionFrom:something) 
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   506
        suspendedContext:thisContext sender;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   507
        parameter:something;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   508
        raise
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   509
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   510
    "Modified: / 2.5.1996 / 16:36:38 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   511
    "Modified: / 5.3.1998 / 16:49:55 / stefan"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   512
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   513
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   514
raiseRequest
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   515
    "raise a signal proceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   516
     The signals notifierString is used as errorString."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   517
4555
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   518
    <context: #return>
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   519
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   520
    ^ self newException 
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   521
        suspendedContext:thisContext sender;
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   522
        raiseRequest.
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   523
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   524
    "Modified: / 2.5.1996 / 16:36:52 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   525
    "Modified: / 5.3.1998 / 16:50:46 / stefan"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   526
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   527
3103
a53892ec3492 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
   528
raiseRequestFrom:something
a53892ec3492 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
   529
    "raise a signal proceedable.
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   530
     The argument, something is passed both as parameter and originator."
3103
a53892ec3492 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
   531
4555
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   532
    <context: #return>
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   533
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   534
    ^ (self newExceptionFrom:something) 
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   535
        suspendedContext:thisContext sender;
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   536
        parameter:something;
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   537
        raiseRequest.
3103
a53892ec3492 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
   538
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   539
    "Modified: / 2.5.1996 / 16:36:38 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   540
    "Modified: / 5.3.1998 / 16:52:46 / stefan"
3103
a53892ec3492 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
   541
!
a53892ec3492 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
   542
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   543
raiseRequestWith:aParameter
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   544
    "raise a signal proceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   545
     The signals notifierString is used as errorString."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   546
4555
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   547
    <context: #return>
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   548
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   549
    ^ self newException
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   550
        suspendedContext:thisContext sender;
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   551
        parameter:aParameter;
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   552
        raiseRequest.
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   553
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   554
    "Modified: / 9.5.1996 / 15:13:20 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   555
    "Modified: / 12.3.1998 / 15:16:57 / stefan"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   556
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   557
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   558
raiseRequestWith:aParameter errorString:aString
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   559
    "raise a signal proceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   560
     The argument, aString is used as errorString."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   561
4555
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   562
    <context: #return>
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   563
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   564
    ^ self newException 
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   565
        suspendedContext:thisContext sender;
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   566
        parameter:aParameter; 
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   567
        errorString:aString;
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   568
        raiseRequest
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   569
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   570
    "Modified: / 9.5.1996 / 15:13:35 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   571
    "Modified: / 12.3.1998 / 15:17:52 / stefan"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   572
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   573
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   574
raiseRequestWith:aParameter errorString:aString in:aContext
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   575
    "raise a signal proceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   576
     The argument, aString is used as errorString.
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   577
     The additional context is passed as the context responsible for the raise,
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   578
     allowing a raise to mimicri the exception happened somewhere else."
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   579
4555
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   580
    ^ self newException 
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   581
        parameter:aParameter; 
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   582
        errorString:aString;
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   583
        suspendedContext:aContext;
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   584
        raiseRequest
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   585
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   586
    "Modified: / 26.7.1996 / 16:29:27 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   587
    "Modified: / 12.3.1998 / 15:18:34 / stefan"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   588
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   589
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   590
raiseWith:aParameter
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   591
    "raise a signal nonproceedable.
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   592
     The argument, aParameter is passed as parameter."
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   593
4555
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   594
    <context: #return>
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   595
4540
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   596
    ^ self newException 
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   597
        suspendedContext:thisContext sender;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   598
        parameter:aParameter;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   599
        raise.
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   600
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   601
    "Modified: / 9.5.1996 / 15:14:24 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   602
    "Modified: / 12.3.1998 / 15:19:11 / stefan"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   603
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   604
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   605
raiseWith:aParameter errorString:aString
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   606
    "raise a signal nonproceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   607
     The argument, aString is used as errorString, aParameter is passed
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   608
     as exception parameter."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   609
4555
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   610
    <context: #return>
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   611
4540
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   612
    ^ self newException 
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   613
        suspendedContext:thisContext sender;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   614
        parameter:aParameter;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   615
        errorString:aString;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   616
        raise.
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   617
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   618
    "Modified: / 9.5.1996 / 15:14:32 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   619
    "Modified: / 12.3.1998 / 15:19:40 / stefan"
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   620
!
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   621
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   622
raiseWith:aParameter errorString:aString in:aContext
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   623
    "raise a signal nonproceedable.
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   624
     The argument, aString is used as errorString, aParameter is passed
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   625
     as exception parameter.
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   626
     The additional context is passed as the context responsible for the raise,
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   627
     allowing a raise to mimicri the exception happened somewhere else."
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   628
4540
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   629
    ^ self newException 
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   630
        parameter:aParameter; 
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   631
        errorString:aString;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   632
        suspendedContext:aContext;
4b99a82fe85a suspendedContext setup explicit
Claus Gittinger <cg@exept.de>
parents: 4527
diff changeset
   633
        raise.
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   634
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   635
    "Created: / 2.5.1996 / 16:37:25 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   636
    "Modified: / 26.7.1996 / 16:29:42 / cg"
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   637
    "Modified: / 12.3.1998 / 15:20:12 / stefan"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   638
! !
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   639
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   640
!Signal methodsFor:'save evaluation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   641
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   642
catch:aBlock
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   643
     "evaluate the argument, aBlock.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   644
      If the receiver-signal is raised during evaluation, abort
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   645
      the evaluation and return true; otherwise return false. 
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   646
      This is the catch & throw mechanism found in other languages,
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   647
      where the returned value indicates if an exception occured."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   648
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   649
      |raiseOccurred|
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   650
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   651
      raiseOccurred := false.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   652
      self handle:[:ex | raiseOccurred := true. ex return] do:aBlock.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   653
      ^ raiseOccurred
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   654
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   655
      "
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   656
       Object messageNotUnderstoodSignal catch:[
4502
097d717941d3 Fix typo
Stefan Vogel <sv@exept.de>
parents: 4493
diff changeset
   657
          123 size open   
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   658
       ]
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   659
      "
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   660
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   661
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   662
handle:handleBlock do:aBlock
a27a279701f8 Initial revision
claus
parents:
diff changeset
   663
    "evaluate the argument, aBlock.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   664
     If the receiver-signal is raised during evaluation,
a27a279701f8 Initial revision
claus
parents:
diff changeset
   665
     evaluate the handleBlock passing it an Exception argument.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   666
     The handler may decide how to react to the signal by sending
a27a279701f8 Initial revision
claus
parents:
diff changeset
   667
     a corresponding message to the exception (see there).
a27a279701f8 Initial revision
claus
parents:
diff changeset
   668
     If the signal is not raised, return the value of evaluating
a27a279701f8 Initial revision
claus
parents:
diff changeset
   669
     aBlock."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   670
4547
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   671
    <context: #return>
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   672
    <exception: #handle>
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   673
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   674
    "/ thisContext markForHandle. -- same as above pragma
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   675
    ^ aBlock value  "the real logic is in Exception>>doRaise"
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
   676
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   677
    "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   678
     Object messageNotUnderstoodSignal handle:[:ex |
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   679
        'oops' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   680
        ex return
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   681
     ] do:[
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   682
        123 size open   
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   683
     ]
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   684
    "
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   685
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   686
    "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   687
     |num|
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   688
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   689
     num := 0.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   690
     Number divisionByZeroSignal handle:[:ex |
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   691
        'oops' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   692
        ex return
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   693
     ] do:[
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   694
        123 / num   
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   695
     ]
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   696
    "
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   697
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   698
    "Modified: / 25.7.1999 / 19:43:01 / stefan"
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   699
!
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   700
362
claus
parents: 345
diff changeset
   701
handle:handleBlock from:anObject do:aBlock
claus
parents: 345
diff changeset
   702
    "evaluate the argument, aBlock.
claus
parents: 345
diff changeset
   703
     If the receiver-signal is raised during evaluation,
claus
parents: 345
diff changeset
   704
     and the exception originated from anObject,
claus
parents: 345
diff changeset
   705
     evaluate the handleBlock passing it an Exception argument.
claus
parents: 345
diff changeset
   706
     The handler may decide how to react to the signal by sending
claus
parents: 345
diff changeset
   707
     a corresponding message to the exception (see there).
claus
parents: 345
diff changeset
   708
     If the signal is not raised, return the value of evaluating
claus
parents: 345
diff changeset
   709
     aBlock."
claus
parents: 345
diff changeset
   710
4547
082a2f7d9d8e Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4540
diff changeset
   711
    <context: #return>
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   712
    <exception: #handle>
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   713
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   714
    "/ thisContext markForHandle. -- same as above pragma
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   715
    ^ aBlock value  "the real logic is in Exception>>doRaise"
362
claus
parents: 345
diff changeset
   716
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   717
    "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   718
     the first open will be caught; the second not:
362
claus
parents: 345
diff changeset
   719
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   720
     |o1 o2|
362
claus
parents: 345
diff changeset
   721
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   722
     o1 := 123.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   723
     o2 := nil.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   724
     Object messageNotUnderstoodSignal 
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   725
         handle:
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   726
              [:ex |
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   727
                  'oops' printNL.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   728
                  ex proceed
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   729
              ] 
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   730
         from:o1
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   731
         do:
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   732
              [
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   733
                  o1 open.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   734
                  o2 open
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   735
              ]
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4486
diff changeset
   736
    "
4438
0b01443d07c1 Add proceedability stuff.
Stefan Vogel <sv@exept.de>
parents: 3521
diff changeset
   737
4464
cec93c942c14 Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents: 4440
diff changeset
   738
    "Modified: / 25.7.1999 / 19:43:40 / stefan"
362
claus
parents: 345
diff changeset
   739
!
claus
parents: 345
diff changeset
   740
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   741
ignoreIn:aBlock
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   742
     "evaluate the argument, aBlock.
4555
892c4529acf2 cleaned up suspendedContext passing.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   743
      Ignore the receiver-signal during evaluation - i.e. simply continue. 
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   744
      This makes only sense for some signals, such as UserInterrupt
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   745
      or AbortSignal, because continuing after an exception without any cleanup
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   746
      often leads to followup-errors."
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   747
4486
f84def7aaf3f replaced #proceed with #proceedWith:nil
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   748
      ^ self handle:[:ex | ex proceedWith:nil] do:aBlock.
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   749
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   750
      "
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   751
       Object messageNotUnderstoodSignal ignoreIn:[
4486
f84def7aaf3f replaced #proceed with #proceedWith:nil
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   752
          123 size open   
61
claus
parents: 44
diff changeset
   753
       ]
claus
parents: 44
diff changeset
   754
      "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   755
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   756
2207
ee6d4213b9df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1610
diff changeset
   757
!Signal class methodsFor:'documentation'!
1249
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   758
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   759
version
4622
905b21c17057 care for non-class nameClass in printOn:
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   760
    ^ '$Header: /cvs/stx/stx/libbasic/Signal.st,v 1.73 1999-08-23 11:57:28 cg Exp $'
1249
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   761
! !