Exception.st
author Claus Gittinger <cg@exept.de>
Fri, 18 Apr 1997 16:39:43 +0200
changeset 2562 e89b40632edc
parent 2509 20e70b07473a
child 2893 8ba406da6b22
permissions -rw-r--r--
removed unused var
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
1118
1037616d9add ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents: 1038
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'
1118
1037616d9add ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
    16
	classVariableNames:'EmergencyHandler RecursiveExceptionSignal'
1037616d9add ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
    17
	poolDictionaries:''
1037616d9add ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
    18
	category:'Kernel-Exceptions'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
1953
c8a3af54acb3 unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
    21
!Exception class methodsFor:'documentation'!
12
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
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    43
	reject          - dont handle this signal;
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    44
			  another handler will be searched for, 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    45
			  upper in the calling hierarchy
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    46
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    47
	proceed         - return from the Signal>>raise, with nil as value
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    48
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    49
	proceedWith:val - same, but return val from Signal>>raise
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    50
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
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
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    53
	returnWith:val  - same, but return val from Signal>>handle:do:
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    54
			  (this is also the handlers default, 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    55
			   if it falls through; taking the handlerBlocks value
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    56
			   as return value)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    57
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
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
1274
5a2f44fe1559 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1118
diff changeset
    65
    [instance variables:]
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    66
	signal           <Signal>     the signal which caused the exception
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    67
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    68
	parameter        <Object>     a parameter (if any) which was passed when raising
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    69
				      the signal (only if raised with #raiseWith:aParameter)
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    70
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    71
	errorString      <String>     an errorString 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    72
				      (usually the signals own errorString, but sometimes
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    73
				       changed explicitely in #raiseWith:errorString:)
44
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
    74
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    75
	suspendedContext <Context>    the context in which the raise occured
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    76
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    77
	handlerContext   <Context>    the context of the handler (if any)
142
c7844287bddf *** empty log message ***
claus
parents: 130
diff changeset
    78
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
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
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
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:
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    89
	Exception emergencyHandler:[:ex | Smalltalk exitWithCoreDump]
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
    90
1274
5a2f44fe1559 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1118
diff changeset
    91
5a2f44fe1559 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1118
diff changeset
    92
    [Class variables:]
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    93
	EmergencyHandler <Block>    this block is evaluated, if no handler was defined
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    94
				    for a signal (i.e. this one is responsible for the
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    95
				    unhandled exception debugger).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    96
				    Having this being a block allows to globally catch
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    97
				    these errors - even when no enclosing handler-scope
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    98
				    around the erronous code exists.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
    99
				    (as the catch/through does).
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   100
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   101
	RecursiveExceptionSignal
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   102
			 <Signal>   raised when within a handler for some signal,
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   103
				    the same signal is raised again.
1274
5a2f44fe1559 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1118
diff changeset
   104
5a2f44fe1559 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1118
diff changeset
   105
5a2f44fe1559 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1118
diff changeset
   106
    [see also:]
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   107
	Signal  SignalSet QuerySignal
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   108
	Context Block
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   109
	Object DebugView
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   110
	(``Exception handling and signals'': programming/exceptions.html)
1292
89497fff7f87 documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   111
89497fff7f87 documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   112
    [author:]
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   113
	Claus Gittinger
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   114
"
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   115
!
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   116
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   117
examples
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   118
"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   119
    Examples on Exception-raising & handling are found in the doc/coding
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   120
    section (CodingExamples).
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   121
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   122
    The emergencyHandler stuff is very useful, to prevent endUser applications
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   123
    from entering the debugger.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   124
    Some commonly used (useful) emergency handlers are provided in the
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   125
    'useful handlers' section; try them to learn more
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   126
    (especially, the mailingHandler is fun).
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   127
2219
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   128
    Of course, these are only examples - you may define your own handler
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   129
    block and pass it to the #emergencyHandler: method.
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   130
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   131
    BTW: the Launchers 'source & debugger' settings menu allows you
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   132
         to install either a default or the notifying handler.
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   133
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   134
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   135
    A handler which shows a box, then aborts - (no more debuggers):
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   136
                                                                [exBegin]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   137
        Exception emergencyHandler:(Exception abortingEmergencyHandler)
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   138
                                                                [exEnd]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   139
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   140
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   141
    A handler which aborts - (no box, no debugger):
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   142
                                                                [exBegin]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   143
        Exception emergencyHandler:[:ex | AbortSignal raise]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   144
                                                                [exEnd]
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   145
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   146
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   147
    try some exception (for demonstration, in some other process):
2219
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   148
                                                                [exBegin]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   149
        [
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   150
            #(1 2 3) at:4
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   151
        ] fork.
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   152
                                                                [exEnd]
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   153
2219
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   154
    cleanup (switch back to the regular handler, which enters the debugger):
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   155
                                                                [exBegin]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   156
        Exception emergencyHandler:nil
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   157
                                                                [exEnd]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   158
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   159
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   160
    A handler which shows a warnBox and asks for debugging:
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   161
                                                                [exBegin]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   162
        Exception emergencyHandler:(Exception notifyingEmergencyHandler)
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   163
                                                                [exEnd]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   164
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   165
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   166
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   167
    A handler which dumps information to a file (watch the file 'errorTrace.stx'):
2219
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   168
                                                                [exBegin]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   169
        Exception emergencyHandler:(Exception dumpingEmergencyHandler)
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   170
                                                                [exEnd]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   171
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   172
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   173
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   174
    A handler which sends you mail:
2219
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   175
                                                                [exBegin]
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   176
        Exception emergencyHandler:(Exception mailingEmergencyHandler)
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   177
                                                                [exEnd]
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   178
"
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   179
! !
3
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   180
1953
c8a3af54acb3 unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   181
!Exception class methodsFor:'initialization'!
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   182
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   183
initialize 
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   184
    "setup the signal used to handle unhandled signals"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   185
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   186
    RecursiveExceptionSignal isNil ifTrue:[
302
1f76060d58a4 *** empty log message ***
claus
parents: 255
diff changeset
   187
	RecursiveExceptionSignal := ErrorSignal newSignalMayProceed:false.
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   188
	RecursiveExceptionSignal nameClass:self message:#recursiveExceptionSignal.
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   189
	RecursiveExceptionSignal notifierString:'recursive signal raise in handler'
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   190
    ]
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   191
! !
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   192
1953
c8a3af54acb3 unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   193
!Exception class methodsFor:'instance creation'!
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   194
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   195
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   196
    "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
   197
     - only to be sent from the signal when raising"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   198
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   199
    ^ (self new)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   200
	signal:aSignal 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   201
	parameter:aParameter 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   202
	errorString:aString 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   203
	suspendedContext:sContext 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   204
	originator:(sContext receiver).
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   205
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   206
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   207
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   208
    "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
   209
     - only to be sent from the signal when raising"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   210
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   211
    ^ (self new)
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   212
	signal:aSignal 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   213
	parameter:aParameter 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   214
	errorString:aString 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   215
	suspendedContext:sContext 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   216
	originator:origin.
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
1953
c8a3af54acb3 unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   219
!Exception class methodsFor:'Signal constants'!
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   220
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   221
recursiveExceptionSignal
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   222
    "return the signal used to handle recursive signals in the handlers"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   223
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   224
    ^ RecursiveExceptionSignal
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   225
! !
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   226
1953
c8a3af54acb3 unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   227
!Exception class methodsFor:'defaults'!
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   228
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   229
emergencyHandler
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   230
    "return the handler used for unhandled exceptions.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   231
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   232
     If no EmergencyHandler has been set, a handler which enters the 
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   233
     debugger is returned.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   234
     The debugger is opened by asking the signal for a debug action,
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   235
     this allows to provide other debuggers in specialized (subclass-instances)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   236
     of Signal (if that is ever needed)"
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   237
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   238
    "
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   239
     set it up, when called the first time
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   240
    "
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   241
    EmergencyHandler isNil ifTrue:[
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   242
	EmergencyHandler := [:ex |
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   243
	    "
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   244
	     sending it to the signal allows per-signal specific
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   245
	     debuggers to be implemented in the future
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   246
	     (for example, segv in primitive code could show things 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   247
	      on the C-level ..)
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   248
	    "
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   249
	    (ex signal) enterDebuggerWith:ex message:(ex errorString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   250
	]
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   251
    ].
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   252
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   253
    ^ EmergencyHandler
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   254
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   255
    "Modified: 15.1.1997 / 20:50:37 / cg"
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   256
!
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   257
130
e09411db2573 emergencyhandler is now a one-arg-block
claus
parents: 92
diff changeset
   258
emergencyHandler:aOneArgBlock
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   259
    "set the handler used for unhandled exceptions.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   260
     The default (a nil-handler) leads to a debugger to be shown."
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   261
130
e09411db2573 emergencyhandler is now a one-arg-block
claus
parents: 92
diff changeset
   262
    EmergencyHandler := aOneArgBlock
362
claus
parents: 345
diff changeset
   263
claus
parents: 345
diff changeset
   264
    "ST-80 behavior of first showing a notifier:
claus
parents: 345
diff changeset
   265
     (I prefer to get right into the debugger, though)
claus
parents: 345
diff changeset
   266
claus
parents: 345
diff changeset
   267
     Exception
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   268
	emergencyHandler:
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   269
	    [:ex | self errorNotify:ex errorString ]
2081
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   270
    "
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   271
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   272
    "ST-X behavior of going right into the debugger:
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   273
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   274
     Exception
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   275
	emergencyHandler:nil
362
claus
parents: 345
diff changeset
   276
    "
claus
parents: 345
diff changeset
   277
claus
parents: 345
diff changeset
   278
    "automatically aborting current operation, on error:
claus
parents: 345
diff changeset
   279
     (may be useful for end-user apps; make certain, 
claus
parents: 345
diff changeset
   280
      you have abortSignal handlers at appropriate places)
claus
parents: 345
diff changeset
   281
claus
parents: 345
diff changeset
   282
     Exception
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   283
	emergencyHandler:
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   284
	    [:ex | Object abortSignal raise. ex return. ]
362
claus
parents: 345
diff changeset
   285
    "
claus
parents: 345
diff changeset
   286
claus
parents: 345
diff changeset
   287
    "finally, traditional language system behavior; dump core ;-)
claus
parents: 345
diff changeset
   288
claus
parents: 345
diff changeset
   289
     Exception
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   290
	emergencyHandler:
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   291
	    [:ex | Smalltalk exitWithCoreDump. ]
362
claus
parents: 345
diff changeset
   292
    "
2081
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   293
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   294
    "Modified: 15.1.1997 / 20:49:06 / cg"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   295
! !
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   296
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   297
!Exception class methodsFor:'useful handlers'!
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   298
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   299
abortingEmergencyHandler
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   300
    "return a block (usable as an emergency handler), 
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   301
     which aborts after showing a warnBox.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   302
     This is useful for endUser applications"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   303
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   304
    ^ [:ex | self warn:'Error: ' , ex errorString.
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   305
	     AbortSignal raise 
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   306
      ]
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   307
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   308
    "test with (try a few halts or CTRL-C's):
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   309
     Exception emergencyHandler:(Exception abortingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   310
    "
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   311
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   312
    "back with:
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   313
     Exception emergencyHandler:(Exception notifyingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   314
     Exception emergencyHandler:nil
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   315
    "
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   316
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   317
    "Created: 15.1.1997 / 20:13:06 / cg"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   318
    "Modified: 15.1.1997 / 20:15:02 / cg"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   319
!
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   320
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   321
dumpingEmergencyHandler
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   322
    "return a block (usable as an emergency handler), 
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   323
     which dumps the stackBacktrace to a trace file and
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   324
     aborts after showing a warnBox.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   325
     This is useful, for endUser application, which are still being
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   326
     debugged (i.e. the programmers may have a look at the traceFile
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   327
     from time to time).
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   328
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   329
     Notice:
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   330
         The code below is just an example; you may want to change the
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   331
         name of the error-file in your application
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   332
         (but please: copy the code; do not modify here)"
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   333
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   334
    ^ [:ex | 
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   335
             |str printedException|
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   336
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   337
             ex signal == Signal noHandlerSignal ifTrue:[
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   338
                printedException := ex parameter.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   339
             ] ifFalse:[
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   340
                printedException := ex
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   341
             ].
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   342
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   343
             "/ user interruption is handled specially:
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   344
             "/ allow user to choose between proceeding or aborting
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   345
             "/ but never dump that information to the file.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   346
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   347
             printedException signal == Object userInterruptSignal ifTrue:[
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   348
                  (self confirm:'abort current action ?') ifTrue:[
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   349
                      AbortSignal raise
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   350
                  ].
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   351
                  ex proceed
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   352
             ].
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   353
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   354
             "/
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   355
             "/ dump it to 'errorTrace.stx'
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   356
             "/
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   357
             str := 'errorTrace.stx' asFilename appendingWriteStream.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   358
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   359
             str nextPutLine:('******************************* '
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   360
                              , AbsoluteTime now printString
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   361
                              , ' *******************************').
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   362
             str cr.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   363
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   364
             str nextPutLine:('** Error: ' , printedException errorString).
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   365
             str nextPutLine:('** Signal: ' , printedException signal printString).
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   366
             str nextPutLine:('** Parameter: ' , printedException parameter printString).
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   367
             str nextPutLine:('** Process: ' , Processor activeProcess printString).
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   368
             str nextPutLine:('** Backtrace:').
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   369
             str cr.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   370
        
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   371
             printedException suspendedContext fullPrintAllOn:str.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   372
             str cr.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   373
             str cr.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   374
             str close.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   375
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   376
             "/ send a line to stdErr
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   377
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   378
             ('[warning]: ignored error: ' , printedException errorString) errorPrintCR.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   379
             ('[warning]:    error information appended to ''errorTrace.stx''') errorPrintCR.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   380
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   381
             AbortSignal raise 
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   382
      ]
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   383
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   384
    "test with (try a few halts or CTRL-C's):
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   385
     Exception emergencyHandler:(Exception dumpingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   386
    "
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   387
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   388
    "back with:
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   389
     Exception emergencyHandler:(Exception notifyingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   390
     Exception emergencyHandler:nil
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   391
    "
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   392
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   393
    "Created: 15.1.1997 / 20:14:52 / cg"
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   394
    "Modified: 24.1.1997 / 20:36:21 / cg"
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   395
!
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   396
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   397
mailingEmergencyHandler
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   398
    "return a block (usable as an emergency handler), 
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   399
     which shows a warnBox and optionally mails a stackBacktrace to a maintainer.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   400
     This is useful, for endUser application, which are still being
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   401
     debugged (i.e. the programmers may have a look at the errors).
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   402
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   403
     Notice: the stuff here is a demonstration only; it should be modified
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   404
	     for your particular environment ...
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   405
	     ... but please: copy the code and modify there;
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   406
	     leave the stuff below as it is."
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   407
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   408
    ^ [:ex | 
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   409
	    |str printedException doMail emergencyMailReceiver pipe|
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   410
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   411
	    ex signal == Signal noHandlerSignal ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   412
	       printedException := ex parameter.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   413
	    ] ifFalse:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   414
	       printedException := ex
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   415
	    ].
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   416
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   417
	     "/ user interruption is handled specially:
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   418
	     "/ allow user to choose between proceeding or aborting
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   419
	     "/ but never dump that information to the file.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   420
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   421
	     printedException signal == Object userInterruptSignal ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   422
		  (self confirm:'abort current action ?') ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   423
		      AbortSignal raise
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   424
		  ].
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   425
		  ex proceed
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   426
	     ].
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   427
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   428
	    "/ somehow get the name of the guy to receive the mail
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   429
	    "/ you have to implement that yourself.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   430
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   431
	    "/ emergencyMailReceiver := OneOfYourClass getEmergencyMailReceiver.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   432
	    emergencyMailReceiver := OperatingSystem getLoginName.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   433
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   434
	    emergencyMailReceiver isNil ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   435
		self warn:(printedException errorString 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   436
			   , '\\No mailing to service people possible.') withCRs.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   437
		doMail := false.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   438
	    ] ifFalse:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   439
		doMail := self confirm:(printedException errorString 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   440
					, '\\Mail error information to the service people (' 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   441
					, emergencyMailReceiver , ') ?') withCRs
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   442
	    ].
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   443
	    doMail ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   444
		str := '' writeStream.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   445
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   446
		str nextPutLine:('Error notification from '
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   447
				, OperatingSystem getLoginName
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   448
				, '@'
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   449
				, OperatingSystem getHostName).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   450
		str cr.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   451
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   452
		str nextPutLine:('Time: ' , AbsoluteTime now printString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   453
		str nextPutLine:('Error: ', printedException errorString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   454
		str nextPutLine:('Signal: ', printedException signal printString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   455
		str nextPutLine:('Parameter: ', printedException parameter printString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   456
		str nextPutLine:('Process: ', Processor activeProcess printString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   457
		str nextPutLine:'Backtrace:'.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   458
		str cr.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   459
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   460
		printedException suspendedContext fullPrintAllOn:str.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   461
		str cr;cr.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   462
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   463
		str close.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   464
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   465
		pipe := PipeStream 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   466
			    writingTo:'mail ', emergencyMailReceiver.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   467
		pipe notNil ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   468
		    pipe nextPutLine:'Subject: automatic error report'.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   469
		    pipe nextPutAll:str contents.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   470
		    pipe cr.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   471
		    pipe close.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   472
		]
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   473
	     ].
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   474
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   475
	     AbortSignal raise 
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   476
      ]
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   477
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   478
    "test with (try a few halts or CTRL-C's):
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   479
     Exception emergencyHandler:(Exception mailingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   480
    "
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   481
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   482
    "back with:
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   483
     Exception emergencyHandler:(Exception notifyingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   484
     Exception emergencyHandler:nil
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   485
    "
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   486
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   487
    "Created: 15.1.1997 / 20:14:52 / cg"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   488
    "Modified: 15.1.1997 / 21:10:28 / cg"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   489
!
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   490
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   491
notifyingEmergencyHandler
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   492
    "return a block (usable as an emergency handler for exceptions), 
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   493
     which does errorNotification before going into the debugger."
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   494
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   495
    ^ [:ex | nil errorNotify:ex errorString from:ex suspendedContext ]
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   496
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   497
    "test with (try a few halts or CTRL-C's):
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   498
     Exception emergencyHandler:(Exception notifyingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   499
    "
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   500
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   501
    "back with:
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   502
     Exception emergencyHandler:nil
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   503
    "
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   504
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   505
    "Modified: 15.1.1997 / 20:15:12 / cg"
362
claus
parents: 345
diff changeset
   506
! !
claus
parents: 345
diff changeset
   507
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   508
!Exception methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   509
44
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   510
errorString 
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   511
    "return the errorString passsed with the signal raise
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   512
     (or nil, if there was none)"
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   513
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   514
    ^ errorString
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   515
!
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   516
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   517
handlerContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   518
    "return the context of the handler"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   519
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   520
    ^ handlerContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   521
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   522
362
claus
parents: 345
diff changeset
   523
originator 
claus
parents: 345
diff changeset
   524
    "return the originator passsed with the signal raise
claus
parents: 345
diff changeset
   525
     (or nil, if there was none)"
claus
parents: 345
diff changeset
   526
claus
parents: 345
diff changeset
   527
    ^ originator
claus
parents: 345
diff changeset
   528
!
claus
parents: 345
diff changeset
   529
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   530
parameter
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   531
    "return the parameter passsed with the signal raise
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   532
     (or nil, if there was none)"
44
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   533
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   534
    ^ parameter
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   535
!
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   536
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   537
rejected
362
claus
parents: 345
diff changeset
   538
    "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
   539
     Uncertain, if this is really interesting to anybody.
362
claus
parents: 345
diff changeset
   540
     This is only valid during handler execution.
claus
parents: 345
diff changeset
   541
     (i.e. an outer handler can find out, if any other handler has already
claus
parents: 345
diff changeset
   542
     rejected).
claus
parents: 345
diff changeset
   543
     "
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   544
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   545
    ^ rejected
362
claus
parents: 345
diff changeset
   546
!
claus
parents: 345
diff changeset
   547
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   548
signal
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   549
    "return the signal, that caused the exception"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   550
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   551
    ^ signal
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   552
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   553
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   554
suspendedContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   555
    "return the context in which the raise occured"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   556
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   557
    ^ suspendedContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   558
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   559
362
claus
parents: 345
diff changeset
   560
willProceed
claus
parents: 345
diff changeset
   561
    "return true, if the exception is proceedable"
claus
parents: 345
diff changeset
   562
claus
parents: 345
diff changeset
   563
    ^ resumeBlock notNil
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   564
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   565
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   566
!Exception methodsFor:'handler actions'!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   567
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   568
proceed
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   569
    "Continue after the raise - the raise returns nil"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   570
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   571
    |b|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   572
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   573
    resumeBlock notNil ifTrue:[
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   574
        b := resumeBlock.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   575
        resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   576
        b value:nil
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   577
    ]
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   578
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   579
    "Modified: 27.3.1997 / 16:44:39 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   580
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   581
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   582
proceedWith:value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   583
    "Continue after the raise - the raise returns value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   584
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   585
    |b|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   586
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   587
    resumeBlock notNil ifTrue:[
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   588
        b := resumeBlock.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   589
        resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   590
        b value:value
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   591
    ]
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   592
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   593
    "Modified: 27.3.1997 / 16:45:57 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   594
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   595
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   596
reject
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   597
    "handler decided not to handle this signal -
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   598
     system will look for another handler"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   599
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   600
    rejected := true.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   601
    rejectBlock value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   602
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   603
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   604
restart
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   605
    "restart the handle:do: - usually after some repair work is done
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   606
     in handler"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   607
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   608
    handlerContext unwindAndRestart
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   609
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   610
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   611
resume
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   612
    "Continue after the raise - the raise returns nil"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   613
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   614
    |b|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   615
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   616
    resumeBlock notNil ifTrue:[
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   617
        b := resumeBlock.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   618
        resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   619
        b value:nil
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   620
    ]
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   621
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   622
    "Modified: 27.3.1997 / 16:45:18 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   623
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   624
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   625
resumeWith:value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   626
    "Continue after the raise - the raise returns value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   627
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   628
    |b|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   629
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   630
    resumeBlock notNil ifTrue:[
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   631
        b := resumeBlock.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   632
        resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   633
        b value:value
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   634
    ]
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   635
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   636
    "Modified: 27.3.1997 / 16:45:41 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   637
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   638
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   639
return
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   640
    "Continue after the handle:do: - the handle:do: returns nil"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   641
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   642
    |con|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   643
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   644
    con := handlerContext.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   645
    resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   646
    con unwind
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   647
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   648
    "Modified: 27.3.1997 / 16:46:39 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   649
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   650
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   651
returnDoing:aBlock
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   652
    "Continue after the handle:do: - the handle:do: returns aBlock value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   653
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   654
    handlerContext unwindThenDo:aBlock
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   655
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   656
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   657
returnWith:value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   658
    "Continue after the handle:do: - the handle:do: returns value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   659
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   660
    |con|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   661
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   662
    con := handlerContext.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   663
    resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   664
    con unwind:value
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   665
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   666
    "Modified: 27.3.1997 / 16:46:51 / cg"
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   667
! !
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   668
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   669
!Exception methodsFor:'raising'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   670
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   671
doCallHandler:aHandler
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   672
    "call the handler proper - needed an extra method
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   673
     to have a separate returnContext for the rejectBlock.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   674
     (which is historical, and actually no longer needed)"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   675
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   676
    |val|
362
claus
parents: 345
diff changeset
   677
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   678
    rejectBlock := [^ self]. "this will return on reject"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   679
    val := aHandler value:self.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   680
    "
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   681
     handler fall through - is just like a returnWith:blocks-value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   682
    "
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   683
    rejectBlock := nil.
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   684
    self returnWith:val
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   685
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   686
1378
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   687
doRaise
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   688
    "search through the context-calling chain for a 'handle:do:'-context 
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   689
     to the raising signal, a parent of it, or a SignalSet which includes 
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   690
     the raising signal.
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   691
     If found, take the contexts 2nd argument (the handler) and evaluate
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   692
     it with the receiver exception as argument.
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   693
     If no handler is found, try per signal handler, or
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   694
     per process handler (if its the noHandlerSignal).
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   695
     Finally fall back to Exceptions emergencyHandler, which is always
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   696
     available and enters the debugger.
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   697
     ATTENTION: the code below depends on being called by #raise or
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   698
     #raiseRequest for proper operation (it skips the sending context)."
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   699
2562
e89b40632edc removed unused var
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   700
    |theContext block noHandlerSignal any msg conArg1
1710
40f0539852ea *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
   701
     theSignal c ex1 activeHandlers inHandler rejected
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   702
     lastHandler h raiseReceiver|
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   703
2433
6eeced763de2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   704
    theContext := thisContext sender sender.  "the raise/raiseRequest-context"
6eeced763de2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   705
                                              "the signal raise context"
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   706
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   707
    theSignal := theContext receiver.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   708
    theSignal isSignal ifFalse:[
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   709
        self halt:'unexpected non-Signal in calling context'.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   710
    ].
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   711
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   712
"/ 'search handler for: ' print. theSignal displayString printCR.
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   713
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   714
    inHandler := false.
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   715
    c := theContext.
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   716
2204
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   717
    "/ since the exceptionHandler is evaluated onTop of the
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   718
    "/ contextChain, we must skip active handlers before searching.
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   719
    "/ otherwise, we get into trouble, when re-raising an exception
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   720
    "/ from within a handler (which would lead to re-executing the
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   721
    "/ same handler)
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   722
    "/ the code below collects active handlers ...
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   723
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   724
    [c notNil] whileTrue:[
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   725
        c := c findNextContextWithSelector:#doRaise or:nil.
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   726
        c notNil ifTrue:[
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   727
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   728
            ex1 := c receiver.
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   729
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   730
            ((ex1 class == self class)
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   731
            or:[ex1 species == self species]) ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   732
                c := c sender.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   733
                (c notNil and:[c receiver == ex1]) ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   734
                    c := c sender.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   735
                    c notNil ifTrue:[
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   736
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   737
                        "/ the common case (really ?) first
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   738
                        ((raiseReceiver := c receiver) == theSignal) ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   739
                            (c selector startsWith:'raise') ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   740
                                h := ex1 handlerContext.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   741
                                h notNil ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   742
                                    activeHandlers isNil ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   743
                                        activeHandlers := OrderedCollection new
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   744
                                    ].
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   745
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   746
                                    lastHandler := h.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   747
                                    activeHandlers add:lastHandler.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   748
                                    inHandler := true.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   749
                                    c := lastHandler.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   750
                                ]
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   751
                            ]
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   752
                        ] ifFalse:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   753
                            raiseReceiver isSignal ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   754
                                (c selector startsWith:'raise') ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   755
                                    h := ex1 handlerContext.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   756
                                    h notNil ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   757
                                        (h receiver accepts:theSignal) ifTrue:[
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   758
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   759
                                            activeHandlers isNil ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   760
                                                activeHandlers := OrderedCollection new
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   761
                                            ].
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   762
                                            lastHandler := h.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   763
                                            activeHandlers add:lastHandler.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   764
                                            inHandler := true.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   765
                                            c := lastHandler.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   766
                                        ]
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   767
                                    ]    
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   768
                                ]    
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   769
                            ]    
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   770
                        ]
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   771
                    ]
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   772
                ]
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   773
            ]
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   774
        ]
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   775
    ].
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   776
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   777
    "/ now, start searching for a handler,
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   778
    "/ start search above the last active handler
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   779
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   780
    lastHandler notNil ifTrue:[
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   781
        theContext := lastHandler.
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   782
    ].
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   783
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   784
    any := false.
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   785
    [theContext notNil] whileTrue:[
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   786
        theContext := theContext findNextContextWithSelector:#'handle:do:' or:#'handle:from:do:'.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   787
        theContext notNil ifTrue:[
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   788
            (theContext selector == #'handle:do:'
2562
e89b40632edc removed unused var
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   789
            or:[(theContext argAt:2) == originator]) 
e89b40632edc removed unused var
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   790
	    ifTrue:[
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   791
                (activeHandlers notNil
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   792
                 and:[activeHandlers includesIdentical:theContext]) ifTrue:[
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   793
                    'skip activeHandler: ' print. theContext displayString printCR.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   794
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   795
                ] ifFalse:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   796
                    "
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   797
                     if this is the Signal>>handle:do: context
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   798
                     or a SignalSet>>handle:do: context with self in it,
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   799
                     call the handler
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   800
                    "
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   801
                    (theContext receiver accepts:signal) ifTrue:[
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   802
                        "call the handler"
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   803
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   804
                        conArg1 := theContext argAt:1.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   805
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   806
                        handlerContext := theContext.
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   807
                        any := true.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   808
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   809
                        self doCallHandler:conArg1.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   810
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   811
                        "if the handler rejects, we arrive here"
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   812
                        "continue search for another handler"
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   813
                        rejected := true.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   814
                    ].
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   815
                ]
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   816
            ]
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   817
        ]
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   818
    ].
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   819
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   820
    activeHandlers := nil.
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   821
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   822
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   823
     we arrive here, if either no handler was found, or none of the
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   824
     handlers did a return (i.e. every handler rejected or fell through).
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   825
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   826
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   827
     try per signal handler
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   828
    "
1038
ab459e9eecc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   829
    (block := signal handlerBlock) isNil ifTrue:[
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   830
        "/
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   831
        "/ if its a querySignal, ignore it
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   832
        "/
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   833
        signal isQuerySignal ifTrue:[^ nil].
1118
1037616d9add ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
   834
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   835
        "/
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   836
        "/ if it is not the NoHandlerSignal, raise it ...
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   837
        "/ passing the receiver as parameter.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   838
        "/
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   839
        signal ~~ (noHandlerSignal := Signal noHandlerSignal) ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   840
            noHandlerSignal notNil ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   841
                any ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   842
                    msg := 'unhandled (rejected)'
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   843
                ] ifFalse:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   844
                    msg := 'unhandled'
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   845
                ].
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   846
                msg := msg , ' exception: (' , errorString , ')'.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   847
                ^ noHandlerSignal 
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   848
                      raiseRequestWith:self 
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   849
                           errorString:msg
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   850
                                    in:self suspendedContext
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   851
            ].
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   852
            "/
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   853
            "/ mhmh - an error during early startup; noHandlerSignal is
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   854
            "/ not yet defined.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   855
            "/
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   856
            ^ MiniDebugger enterWithMessage:errorString
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   857
        ].
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   858
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   859
        "
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   860
         mhmh - smells like trouble - there is no handler and
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   861
         no per-signal handler block.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   862
         Look for either a per-process emergencyHandlerBlock 
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   863
         or the global emergencyHandler (from Exception) ...
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   864
        "
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   865
        Processor notNil ifTrue:[ 
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   866
            "care for signal during startup (Processor not yet created)"
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   867
            block := Processor activeProcess emergencySignalHandler.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   868
        ].
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   869
        block isNil ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   870
            block := Exception emergencyHandler.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   871
            block isNil ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   872
                "care for error during startup (Exception not yet initialized)"
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   873
                ^ MiniDebugger enterWithMessage:errorString
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   874
            ].
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   875
        ].
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   876
    ].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   877
    "... and call it"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   878
    ^ block value:self.
1118
1037616d9add ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
   879
1378
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   880
    "Created: 12.5.1996 / 15:09:39 / cg"
2433
6eeced763de2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   881
    "Modified: 1.3.1997 / 23:53:14 / cg"
1378
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   882
!
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   883
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   884
raise
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   885
    "actually raise a non-proceedable exception.
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   886
     CAVEAT:
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   887
	 For now, in ST/X all signals are proceedable."
1378
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   888
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   889
    resumeBlock := [:value | ^ value].
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   890
    ^ self doRaise
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   891
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   892
    "Modified: 12.5.1996 / 15:09:47 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   893
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   894
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   895
raiseRequest
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   896
    "actually raise a proceedable exception."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   897
1378
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   898
    resumeBlock := [:value | ^ value].
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   899
    ^ self doRaise
1376
6757590defbf avoid extra send (raise->evaluateHandler)
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   900
1378
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   901
    "Modified: 12.5.1996 / 15:09:44 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   902
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   903
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   904
!Exception methodsFor:'setup'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   905
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   906
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   907
    "set the fields usable for inspection by the handler
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   908
     - only to be sent from the signal when raising"
328
claus
parents: 326
diff changeset
   909
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   910
    signal := aSignal.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   911
    parameter := aParameter.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   912
    errorString := aString.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   913
    suspendedContext := sContext.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   914
    originator := origin.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   915
! !
328
claus
parents: 326
diff changeset
   916
1953
c8a3af54acb3 unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   917
!Exception class methodsFor:'documentation'!
662
df7953db3847 version method at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   918
df7953db3847 version method at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   919
version
2562
e89b40632edc removed unused var
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   920
    ^ '$Header: /cvs/stx/stx/libbasic/Exception.st,v 1.53 1997-04-18 14:39:43 cg Exp $'
662
df7953db3847 version method at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   921
! !
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   922
Exception initialize!