Exception.st
author Claus Gittinger <cg@exept.de>
Fri, 09 Feb 1996 13:22:34 +0100
changeset 950 1ead6817a6c8
parent 759 908363ce8a32
child 1038 ab459e9eecc8
permissions -rw-r--r--
dont use con args (use con argAt) - this avoids creating an array copy
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
171
129f0e2e23df handling now in Exception
claus
parents: 142
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:#Exception
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
    14
	 instanceVariableNames:'signal parameter errorString suspendedContext handlerContext
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 662
diff changeset
    15
		rejected originator resumeBlock rejectBlock'
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    16
	 classVariableNames:'EmergencyHandler RecursiveExceptionSignal'
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    17
	 poolDictionaries:''
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    18
	 category:'Kernel-Exceptions'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
    21
!Exception class methodsFor:'documentation'!
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
    22
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    23
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    24
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    25
 COPYRIGHT (c) 1993 by Claus Gittinger
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    26
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    27
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    28
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    29
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    31
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    32
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    33
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    34
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    35
!
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    36
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
    37
documentation
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
    38
"
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
    39
    Instances of Exception are passed to a Signal handling block as argument.
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
    40
    The handler block may perform various actions by sending corresponding messages
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    41
    to the exception object. The following actions are possible:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    42
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    43
	reject          - dont handle this signal;
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    44
			  another handler will be searched for, 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    45
			  upper in the calling hierarchy
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    46
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    47
	proceed         - return from the Signal>>raise, with nil as value
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    48
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    49
	proceedWith:val - same, but return val from Signal>>raise
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    50
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    51
	return          - return from the Signal>>handle:do:, with nil as value
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    52
362
claus
parents: 345
diff changeset
    53
	returnWith:val  - same, but return val from Signal>>handle:do:
claus
parents: 345
diff changeset
    54
			  (this is also the handlers default, 
claus
parents: 345
diff changeset
    55
			   if it falls through; taking the handlerBlocks value
claus
parents: 345
diff changeset
    56
			   as return value)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    57
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    58
	restart         - restart the Signal>>handle:do:, after repairing
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    59
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    60
    Via the Exception object, the handler can also query the state of execution:
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
    61
    where the Signal was raised, where the handler is, the signal which caused
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    62
    the error and the errorString passed when the signal was raised. Also, an optional
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    63
    parameter can be passed - the use is signal specific.:
44
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
    64
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
    65
    instance variables:
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    66
	signal           <Signal>     the signal which caused the exception
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    67
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    68
	parameter        <Object>     a parameter (if any) which was passed when raising
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    69
				      the signal (only if raised with #raiseWith:aParameter)
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    70
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    71
	errorString      <String>     an errorString 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    72
				      (usually the signals own errorString, but sometimes
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    73
				       changed explicitely in #raiseWith:errorString:)
44
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
    74
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    75
	suspendedContext <Context>    the context in which the raise occured
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    76
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    77
	handlerContext   <Context>    the context of the handler (if any)
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    78
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    79
	resumeBlock      <Block>      private to the exception; needed to perform resume action
44
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
    80
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    81
	rejectBlock      <Block>      private to the exception; needed to perform reject action
44
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
    82
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    83
    In case of an unhandled signal raise, Exceptions EmergenyHandler will be evaluated. 
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
    84
    The default emergeny handler will enter the debugger.
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    85
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
    86
    For applications, which do not want Debuggers to come up, other handlers are
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
    87
    possible.
362
claus
parents: 345
diff changeset
    88
    For example, to get the typical C++ behavior, use:
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    89
	Exception emergencyHandler:[:ex | Smalltalk exitWithCoreDump]
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
    90
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
    91
    Class variables:
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    92
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    93
	EmergencyHandler <Block>    this block is evaluated, if no handler was defined
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    94
				    for a signal (i.e. this one is responsible for the
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    95
				    unhandled exception debugger).
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    96
				    Having this being a block allows to globally catch
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    97
				    these errors - even when no enclosing handler-scope
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    98
				    around the erronous code exists.
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
    99
				    (as the catch/through does).
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   100
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   101
	RecursiveExceptionSignal
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   102
			 <Signal>   raised when within a handler for some signal,
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   103
				    th same signal is raised again.
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   104
"
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   105
! !
3
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   106
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   107
!Exception class methodsFor:'initialization'!
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   108
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   109
initialize 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   110
    "setup the signal used to handle unhandled signals"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   111
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   112
    RecursiveExceptionSignal isNil ifTrue:[
302
1f76060d58a4 *** empty log message ***
claus
parents: 255
diff changeset
   113
	RecursiveExceptionSignal := ErrorSignal newSignalMayProceed:false.
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   114
	RecursiveExceptionSignal nameClass:self message:#recursiveExceptionSignal.
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   115
	RecursiveExceptionSignal notifierString:'recursive signal raise in handler'
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   116
    ]
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   117
! !
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   118
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   119
!Exception class methodsFor:'instance creation'!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   120
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   121
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   122
    "create a new instance and set the fields in preparation for a raise.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   123
     - only to be sent from the signal when raising"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   124
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   125
    ^ (self new)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   126
	signal:aSignal 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   127
	parameter:aParameter 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   128
	errorString:aString 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   129
	suspendedContext:sContext 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   130
	originator:(sContext receiver).
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   131
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   132
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   133
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   134
    "create a new instance and set the fields in preparation for a raise.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   135
     - only to be sent from the signal when raising"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   136
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   137
    ^ (self new)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   138
	signal:aSignal 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   139
	parameter:aParameter 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   140
	errorString:aString 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   141
	suspendedContext:sContext 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   142
	originator:origin.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   143
! !
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   144
345
claus
parents: 328
diff changeset
   145
!Exception class methodsFor:'Signal constants'!
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   146
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   147
recursiveExceptionSignal
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   148
    "return the signal used to handle recursive signals in the handlers"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   149
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   150
    ^ RecursiveExceptionSignal
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   151
! !
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   152
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   153
!Exception class methodsFor:'defaults'!
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   154
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   155
emergencyHandler
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   156
    "return the handler used for unhandled exceptions"
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   157
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   158
    "
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   159
     set it up, when called the first time
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   160
    "
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   161
    EmergencyHandler isNil ifTrue:[
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   162
	EmergencyHandler := [:ex |
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   163
	    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   164
	     sending it to the signal allows per-signal specific
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   165
	     debuggers to be implemented in the future
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   166
	     (for example, segv in primitive code could show things 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   167
	      on the C-level ..)
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   168
	    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   169
	    (ex signal) enterDebuggerWith:ex message:(ex errorString).
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   170
	]
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   171
    ].
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   172
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   173
    ^ EmergencyHandler
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   174
!
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   175
130
e09411db2573 emergencyhandler is now a one-arg-block
claus
parents: 92
diff changeset
   176
emergencyHandler:aOneArgBlock
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   177
    "set the handler used for unhandled exceptions"
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   178
130
e09411db2573 emergencyhandler is now a one-arg-block
claus
parents: 92
diff changeset
   179
    EmergencyHandler := aOneArgBlock
362
claus
parents: 345
diff changeset
   180
claus
parents: 345
diff changeset
   181
    "ST-80 behavior of first showing a notifier:
claus
parents: 345
diff changeset
   182
     (I prefer to get right into the debugger, though)
claus
parents: 345
diff changeset
   183
claus
parents: 345
diff changeset
   184
     Exception
claus
parents: 345
diff changeset
   185
	emergencyHandler:
547
7772f34ce597 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   186
	    [:ex | self errorNotify:ex errorString ]
362
claus
parents: 345
diff changeset
   187
    "
claus
parents: 345
diff changeset
   188
claus
parents: 345
diff changeset
   189
    "automatically aborting current operation, on error:
claus
parents: 345
diff changeset
   190
     (may be useful for end-user apps; make certain, 
claus
parents: 345
diff changeset
   191
      you have abortSignal handlers at appropriate places)
claus
parents: 345
diff changeset
   192
claus
parents: 345
diff changeset
   193
     Exception
claus
parents: 345
diff changeset
   194
	emergencyHandler:
claus
parents: 345
diff changeset
   195
	    [:ex | Object abortSignal raise. ex return. ]
claus
parents: 345
diff changeset
   196
    "
claus
parents: 345
diff changeset
   197
claus
parents: 345
diff changeset
   198
    "finally, traditional language system behavior; dump core ;-)
claus
parents: 345
diff changeset
   199
claus
parents: 345
diff changeset
   200
     Exception
claus
parents: 345
diff changeset
   201
	emergencyHandler:
claus
parents: 345
diff changeset
   202
	    [:ex | Smalltalk exitWithCoreDump. ]
claus
parents: 345
diff changeset
   203
    "
claus
parents: 345
diff changeset
   204
! !
claus
parents: 345
diff changeset
   205
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   206
!Exception methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   207
44
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   208
errorString 
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   209
    "return the errorString passsed with the signal raise
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   210
     (or nil, if there was none)"
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   211
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   212
    ^ errorString
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   213
!
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   214
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   215
handlerContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   216
    "return the context of the handler"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   217
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   218
    ^ handlerContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   219
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   220
362
claus
parents: 345
diff changeset
   221
originator 
claus
parents: 345
diff changeset
   222
    "return the originator passsed with the signal raise
claus
parents: 345
diff changeset
   223
     (or nil, if there was none)"
claus
parents: 345
diff changeset
   224
claus
parents: 345
diff changeset
   225
    ^ originator
claus
parents: 345
diff changeset
   226
!
claus
parents: 345
diff changeset
   227
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   228
parameter
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   229
    "return the parameter passsed with the signal raise
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   230
     (or nil, if there was none)"
44
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   231
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   232
    ^ parameter
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   233
!
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   234
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   235
rejected
362
claus
parents: 345
diff changeset
   236
    "return true, if any other of the exceptions handlers has rejected 
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 662
diff changeset
   237
     Uncertain, if this is really interesting to anybody.
362
claus
parents: 345
diff changeset
   238
     This is only valid during handler execution.
claus
parents: 345
diff changeset
   239
     (i.e. an outer handler can find out, if any other handler has already
claus
parents: 345
diff changeset
   240
     rejected).
claus
parents: 345
diff changeset
   241
     "
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   242
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   243
    ^ rejected
362
claus
parents: 345
diff changeset
   244
!
claus
parents: 345
diff changeset
   245
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   246
signal
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   247
    "return the signal, that caused the exception"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   248
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   249
    ^ signal
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   250
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   251
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   252
suspendedContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   253
    "return the context in which the raise occured"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   254
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   255
    ^ suspendedContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   256
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   257
362
claus
parents: 345
diff changeset
   258
willProceed
claus
parents: 345
diff changeset
   259
    "return true, if the exception is proceedable"
claus
parents: 345
diff changeset
   260
claus
parents: 345
diff changeset
   261
    ^ resumeBlock notNil
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   262
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   263
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   264
!Exception methodsFor:'handler actions'!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   265
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   266
proceed
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   267
    "Continue after the raise - the raise returns nil"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   268
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   269
    resumeBlock notNil ifTrue:[resumeBlock value:nil]
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   270
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   271
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   272
proceedWith:value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   273
    "Continue after the raise - the raise returns value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   274
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   275
    resumeBlock notNil ifTrue:[resumeBlock value:value]
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   276
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   277
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   278
reject
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   279
    "handler decided not to handle this signal -
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   280
     system will look for another handler"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   281
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   282
    rejected := true.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   283
    rejectBlock value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   284
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   285
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   286
restart
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   287
    "restart the handle:do: - usually after some repair work is done
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   288
     in handler"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   289
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   290
    handlerContext unwindAndRestart
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   291
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   292
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   293
resume
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   294
    "Continue after the raise - the raise returns nil"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   295
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   296
    resumeBlock notNil ifTrue:[resumeBlock value:nil]
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   297
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   298
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   299
resumeWith:value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   300
    "Continue after the raise - the raise returns value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   301
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   302
    resumeBlock notNil ifTrue:[resumeBlock value:value]
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   303
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   304
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   305
return
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   306
    "Continue after the handle:do: - the handle:do: returns nil"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   307
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   308
    handlerContext unwind
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   309
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   310
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   311
returnDoing:aBlock
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   312
    "Continue after the handle:do: - the handle:do: returns aBlock value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   313
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   314
    handlerContext unwindThenDo:aBlock
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   315
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   316
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   317
returnWith:value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   318
    "Continue after the handle:do: - the handle:do: returns value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   319
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   320
    handlerContext unwind:value
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   321
! !
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   322
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   323
!Exception methodsFor:'raising'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   324
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   325
doCallHandler:aHandler
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   326
    "call the handler proper - needed an extra method
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   327
     to have a separate returnContext for the rejectBlock.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   328
     (which is historical, and actually no longer needed)"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   329
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   330
    |val|
362
claus
parents: 345
diff changeset
   331
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   332
    rejectBlock := [^ self]. "this will return on reject"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   333
    val := aHandler value:self.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   334
    "
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   335
     handler fall through - is just like a returnWith:blocks-value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   336
    "
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   337
    self returnWith:val
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   338
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   339
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   340
evaluateHandler
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   341
    "search through the context-calling chain for a 'handle:do:'-context 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   342
     to the raising signal a parent of it or a SignalSet which includes 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   343
     the raising signal.
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   344
     If found, take the contexts 2nd argument (the handler) and evaluate
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   345
     it with the receiver exception as argument.
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   346
     If no handler is found, try per signal handler, or
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   347
     per process handler (if its the noHandlerSignal).
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   348
     Finally fall back to Exceptions emergencyHandler, which is always
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   349
     available and enters the debugger."
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   350
950
1ead6817a6c8 dont use con args (use con argAt) - this avoids creating an array copy
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   351
    |con block noHandlerSignal any msg sel activeHandler conArg1|
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   352
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   353
    con := thisContext sender.  "the raise-context"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   354
    con := con sender.          "the signal raise context"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   355
    con isRecursive ifTrue:[
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   356
	"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   357
	 mhmh - an error while in a handler
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   358
	"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   359
	((signal == RecursiveExceptionSignal)
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   360
	or:[RecursiveExceptionSignal isNil]) ifTrue:[
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   361
	    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   362
	     ... either while handling RecursiveExceptionSignal
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   363
	     or at startup when RecursiveExceptionSignal is not yet
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   364
	     created -
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   365
	     - go immediately into the debugger.
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   366
	    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   367
	    ^ self enterDebuggerWith:self
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   368
			     message:'recursive signal raise'
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   369
	].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   370
	^ RecursiveExceptionSignal 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   371
	    raiseRequestWith:self 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   372
		 errorString:('recursive signal raise: ' , errorString)
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   373
    ].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   374
362
claus
parents: 345
diff changeset
   375
    any := false.
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   376
    [con notNil] whileTrue:[
362
claus
parents: 345
diff changeset
   377
	con isBlockContext ifFalse:[
367
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   378
	    sel := con selector.
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   379
	    sel == #doCallHandler: ifTrue:[
950
1ead6817a6c8 dont use con args (use con argAt) - this avoids creating an array copy
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   380
		activeHandler := con argAt:1
367
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   381
	    ].
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   382
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   383
	    ((sel == #'handle:do:') 
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   384
	    or:[((sel == #'handle:from:do:') 
950
1ead6817a6c8 dont use con args (use con argAt) - this avoids creating an array copy
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   385
		and:[(con argAt:2) == originator])]) ifTrue:[
362
claus
parents: 345
diff changeset
   386
		"
claus
parents: 345
diff changeset
   387
		 if this is the Signal>>handle:do: context
claus
parents: 345
diff changeset
   388
		 or a SignalSet>>handle:do: context with self in it,
claus
parents: 345
diff changeset
   389
		 call the handler
claus
parents: 345
diff changeset
   390
		"
claus
parents: 345
diff changeset
   391
		(con receiver accepts:signal) ifTrue:[
claus
parents: 345
diff changeset
   392
		    "call the handler"
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   393
950
1ead6817a6c8 dont use con args (use con argAt) - this avoids creating an array copy
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   394
		    conArg1 := con argAt:1.
1ead6817a6c8 dont use con args (use con argAt) - this avoids creating an array copy
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   395
		    activeHandler == conArg1 ifTrue:[
367
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   396
"/                        'skip active handler:' print.
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   397
"/                        con print. ' ' print. con receiver print.
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   398
"/                        ' for ' print. signal printNL
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   399
		    ] ifFalse:[
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   400
			handlerContext := con.
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   401
			any := true.
950
1ead6817a6c8 dont use con args (use con argAt) - this avoids creating an array copy
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   402
			self doCallHandler:conArg1.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   403
367
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   404
			"if the handler rejects, we arrive here"
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   405
			"continue search for another handler"
a2114577b799 *** empty log message ***
claus
parents: 362
diff changeset
   406
		    ]
362
claus
parents: 345
diff changeset
   407
		].
claus
parents: 345
diff changeset
   408
	    ]
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   409
	].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   410
	con := con sender
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   411
    ].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   412
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   413
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   414
     we arrive here, if either no handler was found, or none of the
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   415
     handlers did a return (i.e. every handler rejected or fell through).
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   416
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   417
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   418
     try per signal handler
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   419
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   420
    (block := signal handlerBlock) notNil ifTrue:[
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   421
	^ block value:self.
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   422
    ].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   423
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   424
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   425
     if it is not the NoHandlerSignal, raise it ...
213
3b56a17534fd *** empty log message ***
claus
parents: 171
diff changeset
   426
     passing the receiver as parameter.
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   427
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   428
    signal ~~ (noHandlerSignal := Signal noHandlerSignal) ifTrue:[
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   429
	noHandlerSignal notNil ifTrue:[
362
claus
parents: 345
diff changeset
   430
	    any ifTrue:[
claus
parents: 345
diff changeset
   431
		msg := 'unhandled (rejected)'
claus
parents: 345
diff changeset
   432
	    ] ifFalse:[
claus
parents: 345
diff changeset
   433
		msg := 'unhandled'
claus
parents: 345
diff changeset
   434
	    ].
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   435
	    ^ noHandlerSignal 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   436
		  raiseRequestWith:self 
362
claus
parents: 345
diff changeset
   437
		       errorString:(msg , ' exception: ' , errorString)
255
2b2c5c0facab *** empty log message ***
claus
parents: 249
diff changeset
   438
				in:self suspendedContext
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   439
	].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   440
	"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   441
	 mhmh - an error during early startup; noHandlerSignal is
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   442
	 not yet defined.
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   443
	"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   444
	^ MiniDebugger enterWithMessage:errorString
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   445
    ].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   446
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   447
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   448
     mhmh - smells like trouble - there is no handler and
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   449
     no per-signal handler block.
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   450
     Look for either a per-process emergencyHandlerBlock 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   451
     or the global emergencyHandler (from Exception) ...
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   452
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   453
    Processor notNil ifTrue:[ 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   454
	"care for signal during startup (Processor not yet created)"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   455
	block := Processor activeProcess emergencySignalHandler.
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   456
    ].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   457
    block isNil ifTrue:[
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   458
	block := Exception emergencyHandler
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   459
    ].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   460
    block isNil ifTrue:[
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   461
	"care for error during startup (Exception not yet initialized)"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   462
	^ MiniDebugger enterWithMessage:errorString
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   463
    ].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   464
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   465
    "... and call it"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   466
    ^ block value:self.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   467
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   468
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   469
raise
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   470
    "actually raise a nonproceedable exception.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   471
     For now, same as #raiseRequest (always proceedable)."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   472
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   473
    resumeBlock := [:value | ^ value].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   474
    ^ self evaluateHandler
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   475
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   476
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   477
raiseRequest
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   478
    "actually raise a proceedable exception."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   479
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   480
    resumeBlock := [:value | ^ value].
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   481
    ^ self evaluateHandler
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   482
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   483
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   484
!Exception methodsFor:'setup'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   485
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   486
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   487
    "set the fields usable for inspection by the handler
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   488
     - only to be sent from the signal when raising"
328
claus
parents: 326
diff changeset
   489
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   490
    signal := aSignal.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   491
    parameter := aParameter.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   492
    errorString := aString.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   493
    suspendedContext := sContext.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   494
    originator := origin.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   495
! !
328
claus
parents: 326
diff changeset
   496
662
df7953db3847 version method at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   497
!Exception class methodsFor:'documentation'!
df7953db3847 version method at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   498
df7953db3847 version method at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   499
version
950
1ead6817a6c8 dont use con args (use con argAt) - this avoids creating an array copy
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   500
    ^ '$Header: /cvs/stx/stx/libbasic/Exception.st,v 1.31 1996-02-09 12:22:34 cg Exp $'
662
df7953db3847 version method at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   501
! !
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   502
Exception initialize!