Exception.st
author Claus Gittinger <cg@exept.de>
Sat, 15 Nov 1997 15:06:27 +0100
changeset 3111 a23fa6d08ce7
parent 3110 9a1e3a736e14
child 3179 f22e94c6ae83
permissions -rw-r--r--
*** empty log message ***
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
3091
eca3dfaa92c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3068
diff changeset
   199
    "{ Pragma: +inlineNew }"
eca3dfaa92c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3068
diff changeset
   200
3017
cdd87208ae2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3011
diff changeset
   201
    ^ (self basicNew)
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   202
	signal:aSignal 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   203
	parameter:aParameter 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   204
	errorString:aString 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   205
	suspendedContext:sContext 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   206
	originator:(sContext receiver).
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   207
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   208
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   209
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   210
    "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
   211
     - only to be sent from the signal when raising"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   212
3091
eca3dfaa92c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3068
diff changeset
   213
    "{ Pragma: +inlineNew }"
eca3dfaa92c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3068
diff changeset
   214
3017
cdd87208ae2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3011
diff changeset
   215
    ^ (self basicNew)
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   216
	signal:aSignal 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   217
	parameter:aParameter 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   218
	errorString:aString 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   219
	suspendedContext:sContext 
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   220
	originator:origin.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   221
! !
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   222
1953
c8a3af54acb3 unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   223
!Exception class methodsFor:'Signal constants'!
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   224
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   225
recursiveExceptionSignal
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   226
    "return the signal used to handle recursive signals in the handlers"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   227
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   228
    ^ RecursiveExceptionSignal
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   229
! !
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   230
1953
c8a3af54acb3 unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   231
!Exception class methodsFor:'defaults'!
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   232
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   233
emergencyHandler
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   234
    "return the handler used for unhandled exceptions.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   235
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   236
     If no EmergencyHandler has been set, a handler which enters the 
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   237
     debugger is returned.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   238
     The debugger is opened by asking the signal for a debug action,
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   239
     this allows to provide other debuggers in specialized (subclass-instances)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   240
     of Signal (if that is ever needed)"
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   241
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   242
    "
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   243
     set it up, when called the first time
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   244
    "
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   245
    EmergencyHandler isNil ifTrue:[
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   246
	EmergencyHandler := [:ex |
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   247
	    "
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   248
	     sending it to the signal allows per-signal specific
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   249
	     debuggers to be implemented in the future
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   250
	     (for example, segv in primitive code could show things 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   251
	      on the C-level ..)
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   252
	    "
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   253
	    (ex signal) enterDebuggerWith:ex message:(ex errorString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   254
	]
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   255
    ].
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   256
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   257
    ^ EmergencyHandler
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   258
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   259
    "Modified: 15.1.1997 / 20:50:37 / cg"
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   260
!
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
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   263
    "set the handler used for unhandled exceptions.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   264
     The default (a nil-handler) leads to a debugger to be shown."
12
8e03bd717355 *** empty log message ***
claus
parents: 3
diff changeset
   265
130
e09411db2573 emergencyhandler is now a one-arg-block
claus
parents: 92
diff changeset
   266
    EmergencyHandler := aOneArgBlock
362
claus
parents: 345
diff changeset
   267
claus
parents: 345
diff changeset
   268
    "ST-80 behavior of first showing a notifier:
claus
parents: 345
diff changeset
   269
     (I prefer to get right into the debugger, though)
claus
parents: 345
diff changeset
   270
claus
parents: 345
diff changeset
   271
     Exception
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   272
	emergencyHandler:
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   273
	    [:ex | self errorNotify:ex errorString ]
2081
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   274
    "
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   275
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   276
    "ST-X behavior of going right into the debugger:
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   277
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   278
     Exception
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   279
	emergencyHandler:nil
362
claus
parents: 345
diff changeset
   280
    "
claus
parents: 345
diff changeset
   281
claus
parents: 345
diff changeset
   282
    "automatically aborting current operation, on error:
claus
parents: 345
diff changeset
   283
     (may be useful for end-user apps; make certain, 
claus
parents: 345
diff changeset
   284
      you have abortSignal handlers at appropriate places)
claus
parents: 345
diff changeset
   285
claus
parents: 345
diff changeset
   286
     Exception
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   287
	emergencyHandler:
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   288
	    [:ex | Object abortSignal raise. ex return. ]
362
claus
parents: 345
diff changeset
   289
    "
claus
parents: 345
diff changeset
   290
claus
parents: 345
diff changeset
   291
    "finally, traditional language system behavior; dump core ;-)
claus
parents: 345
diff changeset
   292
claus
parents: 345
diff changeset
   293
     Exception
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   294
	emergencyHandler:
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   295
	    [:ex | Smalltalk exitWithCoreDump. ]
362
claus
parents: 345
diff changeset
   296
    "
2081
f16d9b47a0b0 comment
Claus Gittinger <cg@exept.de>
parents: 1953
diff changeset
   297
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   298
    "Modified: 15.1.1997 / 20:49:06 / cg"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   299
! !
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   300
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   301
!Exception class methodsFor:'useful handlers'!
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   302
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   303
abortingEmergencyHandler
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   304
    "return a block (usable as an emergency handler), 
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   305
     which aborts after showing a warnBox.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   306
     This is useful for endUser applications"
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
    ^ [:ex | self warn:'Error: ' , ex errorString.
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   309
	     AbortSignal raise 
2174
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
    "test with (try a few halts or CTRL-C's):
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   313
     Exception emergencyHandler:(Exception abortingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   314
    "
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
    "back with:
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   317
     Exception emergencyHandler:(Exception notifyingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   318
     Exception emergencyHandler:nil
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
    "Created: 15.1.1997 / 20:13:06 / cg"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   322
    "Modified: 15.1.1997 / 20:15:02 / cg"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   323
!
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   324
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   325
dumpingEmergencyHandler
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   326
    "return a block (usable as an emergency handler), 
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   327
     which dumps the stackBacktrace to a trace file and
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   328
     aborts after showing a warnBox.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   329
     This is useful, for endUser application, which are still being
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   330
     debugged (i.e. the programmers may have a look at the traceFile
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   331
     from time to time).
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   332
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   333
     Notice:
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   334
         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
   335
         name of the error-file in your application
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   336
         (but please: copy the code; do not modify here)"
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   337
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   338
    ^ [:ex | 
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   339
             |str printedException|
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   340
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   341
             ex signal == Signal noHandlerSignal ifTrue:[
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   342
                printedException := ex parameter.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   343
             ] ifFalse:[
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   344
                printedException := ex
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   345
             ].
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   346
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   347
             "/ user interruption is handled specially:
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   348
             "/ allow user to choose between proceeding or aborting
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   349
             "/ but never dump that information to the file.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   350
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   351
             printedException signal == Object userInterruptSignal ifTrue:[
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   352
                  (self confirm:'abort current action ?') ifTrue:[
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   353
                      AbortSignal raise
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
                  ex proceed
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   356
             ].
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   357
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   358
             "/
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   359
             "/ dump it to 'errorTrace.stx'
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   360
             "/
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   361
             str := 'errorTrace.stx' asFilename appendingWriteStream.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   362
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   363
             str nextPutLine:('******************************* '
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   364
                              , AbsoluteTime now printString
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   365
                              , ' *******************************').
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   366
             str cr.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   367
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   368
             str nextPutLine:('** Error: ' , printedException errorString).
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   369
             str nextPutLine:('** Signal: ' , printedException signal printString).
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   370
             str nextPutLine:('** Parameter: ' , printedException parameter printString).
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   371
             str nextPutLine:('** Process: ' , Processor activeProcess printString).
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   372
             str nextPutLine:('** Backtrace:').
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   373
             str cr.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   374
        
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   375
             printedException suspendedContext fullPrintAllOn:str.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   376
             str cr.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   377
             str cr.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   378
             str close.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   379
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   380
             "/ send a line to stdErr
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   381
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   382
             ('[warning]: ignored error: ' , printedException errorString) errorPrintCR.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   383
             ('[warning]:    error information appended to ''errorTrace.stx''') errorPrintCR.
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   384
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   385
             AbortSignal raise 
2174
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
    "test with (try a few halts or CTRL-C's):
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   389
     Exception emergencyHandler:(Exception dumpingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   390
    "
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
    "back with:
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   393
     Exception emergencyHandler:(Exception notifyingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   394
     Exception emergencyHandler:nil
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
    "Created: 15.1.1997 / 20:14:52 / cg"
2257
1d9e88f6550e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2219
diff changeset
   398
    "Modified: 24.1.1997 / 20:36:21 / cg"
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   399
!
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   400
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   401
mailingEmergencyHandler
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   402
    "return a block (usable as an emergency handler), 
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   403
     which shows a warnBox and optionally mails a stackBacktrace to a maintainer.
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   404
     This is useful, for endUser application, which are still being
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   405
     debugged (i.e. the programmers may have a look at the errors).
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   406
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   407
     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
   408
	     for your particular environment ...
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   409
	     ... but please: copy the code and modify there;
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   410
	     leave the stuff below as it is."
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   411
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   412
    ^ [:ex | 
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   413
	    |str printedException doMail emergencyMailReceiver pipe|
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   414
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   415
	    ex signal == Signal noHandlerSignal ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   416
	       printedException := ex parameter.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   417
	    ] ifFalse:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   418
	       printedException := ex
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   419
	    ].
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
	     "/ user interruption is handled specially:
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   422
	     "/ allow user to choose between proceeding or aborting
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   423
	     "/ but never dump that information to the file.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   424
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   425
	     printedException signal == Object userInterruptSignal ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   426
		  (self confirm:'abort current action ?') ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   427
		      AbortSignal raise
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   428
		  ].
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   429
		  ex proceed
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   430
	     ].
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   431
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   432
	    "/ somehow get the name of the guy to receive the mail
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   433
	    "/ you have to implement that yourself.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   434
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   435
	    "/ emergencyMailReceiver := OneOfYourClass getEmergencyMailReceiver.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   436
	    emergencyMailReceiver := OperatingSystem getLoginName.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   437
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   438
	    emergencyMailReceiver isNil ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   439
		self warn:(printedException errorString 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   440
			   , '\\No mailing to service people possible.') withCRs.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   441
		doMail := false.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   442
	    ] ifFalse:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   443
		doMail := self confirm:(printedException errorString 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   444
					, '\\Mail error information to the service people (' 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   445
					, emergencyMailReceiver , ') ?') withCRs
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   446
	    ].
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   447
	    doMail ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   448
		str := '' writeStream.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   449
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   450
		str nextPutLine:('Error notification from '
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   451
				, OperatingSystem getLoginName
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   452
				, '@'
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   453
				, OperatingSystem getHostName).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   454
		str cr.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   455
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   456
		str nextPutLine:('Time: ' , AbsoluteTime now printString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   457
		str nextPutLine:('Error: ', printedException errorString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   458
		str nextPutLine:('Signal: ', printedException signal printString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   459
		str nextPutLine:('Parameter: ', printedException parameter printString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   460
		str nextPutLine:('Process: ', Processor activeProcess printString).
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   461
		str nextPutLine:'Backtrace:'.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   462
		str cr.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   463
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   464
		printedException suspendedContext fullPrintAllOn:str.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   465
		str cr;cr.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   466
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   467
		str close.
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   468
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   469
		pipe := PipeStream 
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   470
			    writingTo:'mail ', emergencyMailReceiver.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   471
		pipe notNil ifTrue:[
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   472
		    pipe nextPutLine:'Subject: automatic error report'.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   473
		    pipe nextPutAll:str contents.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   474
		    pipe cr.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   475
		    pipe close.
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   476
		]
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   477
	     ].
2174
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   478
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   479
	     AbortSignal raise 
2174
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
    "test with (try a few halts or CTRL-C's):
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   483
     Exception emergencyHandler:(Exception mailingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   484
    "
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
    "back with:
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   487
     Exception emergencyHandler:(Exception notifyingEmergencyHandler)
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   488
     Exception emergencyHandler:nil
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
    "Created: 15.1.1997 / 20:14:52 / cg"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   492
    "Modified: 15.1.1997 / 21:10:28 / cg"
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   493
!
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
notifyingEmergencyHandler
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   496
    "return a block (usable as an emergency handler for exceptions), 
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   497
     which does errorNotification before going into the debugger."
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   498
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   499
    ^ [:ex | nil errorNotify:ex errorString from:ex suspendedContext ]
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
    "test with (try a few halts or CTRL-C's):
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   502
     Exception emergencyHandler:(Exception notifyingEmergencyHandler)
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
    "back with:
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   506
     Exception emergencyHandler:nil
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   507
    "
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   508
3c6300f27f74 example section;
Claus Gittinger <cg@exept.de>
parents: 2081
diff changeset
   509
    "Modified: 15.1.1997 / 20:15:12 / cg"
362
claus
parents: 345
diff changeset
   510
! !
claus
parents: 345
diff changeset
   511
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   512
!Exception methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   513
44
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   514
errorString 
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   515
    "return the errorString passsed with the signal raise
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   516
     (or nil, if there was none)"
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   517
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   518
    ^ errorString
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   519
!
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   520
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   521
handlerContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   522
    "return the context of the handler"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   523
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   524
    ^ handlerContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   525
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   526
362
claus
parents: 345
diff changeset
   527
originator 
claus
parents: 345
diff changeset
   528
    "return the originator passsed with the signal raise
claus
parents: 345
diff changeset
   529
     (or nil, if there was none)"
claus
parents: 345
diff changeset
   530
claus
parents: 345
diff changeset
   531
    ^ originator
claus
parents: 345
diff changeset
   532
!
claus
parents: 345
diff changeset
   533
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   534
parameter
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   535
    "return the parameter passsed with the signal raise
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   536
     (or nil, if there was none)"
44
b262907c93ea *** empty log message ***
claus
parents: 12
diff changeset
   537
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   538
    ^ parameter
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   539
!
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   540
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   541
rejected
362
claus
parents: 345
diff changeset
   542
    "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
   543
     Uncertain, if this is really interesting to anybody.
362
claus
parents: 345
diff changeset
   544
     This is only valid during handler execution.
claus
parents: 345
diff changeset
   545
     (i.e. an outer handler can find out, if any other handler has already
claus
parents: 345
diff changeset
   546
     rejected).
claus
parents: 345
diff changeset
   547
     "
68
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   548
59faa75185ba *** empty log message ***
claus
parents: 54
diff changeset
   549
    ^ rejected
362
claus
parents: 345
diff changeset
   550
!
claus
parents: 345
diff changeset
   551
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   552
signal
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   553
    "return the signal, that caused the exception"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   554
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   555
    ^ signal
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
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   558
suspendedContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   559
    "return the context in which the raise occured"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   560
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   561
    ^ suspendedContext
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   562
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   563
362
claus
parents: 345
diff changeset
   564
willProceed
claus
parents: 345
diff changeset
   565
    "return true, if the exception is proceedable"
claus
parents: 345
diff changeset
   566
claus
parents: 345
diff changeset
   567
    ^ resumeBlock notNil
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   568
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   569
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   570
!Exception methodsFor:'handler actions'!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   571
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   572
proceed
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   573
    "Continue after the raise - the raise returns nil"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   574
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   575
    |b|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   576
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   577
    resumeBlock notNil ifTrue:[
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   578
        b := resumeBlock.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   579
        resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   580
        b value:nil
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   581
    ]
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   582
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   583
    "Modified: 27.3.1997 / 16:44:39 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   584
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   585
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   586
proceedWith:value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   587
    "Continue after the raise - the raise returns value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   588
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   589
    |b|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   590
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   591
    resumeBlock notNil ifTrue:[
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   592
        b := resumeBlock.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   593
        resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   594
        b value:value
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   595
    ]
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   596
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   597
    "Modified: 27.3.1997 / 16:45:57 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   598
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   599
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   600
reject
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   601
    "handler decided not to handle this signal -
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   602
     system will look for another handler"
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
    rejected := true.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   605
    rejectBlock value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   606
!
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
restart
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   609
    "restart the handle:do: - usually after some repair work is done
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   610
     in handler"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   611
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   612
    handlerContext unwindAndRestart
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   613
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   614
3100
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   615
restartDo:aBlock
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   616
    "restart the handle:do: but execute the argument, aBlock instead of the
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   617
     original do-block - usually after some repair work is done in handler"
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   618
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   619
    handlerContext argAt:2 put:aBlock.
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   620
    handlerContext unwindAndRestart
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   621
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   622
    "
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   623
     |sig rslt|
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   624
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   625
     sig := Signal new.
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   626
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   627
     sig handle:[:ex |
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   628
        ex restartDo:[ rslt := 999 ]
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   629
     ] do:[
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   630
        rslt := 0.
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   631
        sig raise
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   632
     ].
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   633
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   634
     Transcript showCR:rslt
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   635
    "
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   636
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   637
    "Modified: / 8.11.1997 / 18:52:28 / cg"
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   638
!
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   639
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   640
resume
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   641
    "Continue after the raise - the raise returns nil"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   642
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   643
    |b|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   644
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   645
    resumeBlock notNil ifTrue:[
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   646
        b := resumeBlock.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   647
        resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   648
        b value:nil
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   649
    ]
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   650
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   651
    "Modified: 27.3.1997 / 16:45:18 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   652
!
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
resumeWith:value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   655
    "Continue after the raise - the raise returns value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   656
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   657
    |b|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   658
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   659
    resumeBlock notNil ifTrue:[
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   660
        b := resumeBlock.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   661
        resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   662
        b value:value
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   663
    ]
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   664
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   665
    "Modified: 27.3.1997 / 16:45:41 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   666
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   667
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   668
return
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   669
    "Continue after the handle:do: - the handle:do: returns nil"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   670
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   671
    |con|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   672
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   673
    con := handlerContext.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   674
    resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   675
    con unwind
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   676
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   677
    "Modified: 27.3.1997 / 16:46:39 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   678
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   679
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   680
returnDoing:aBlock
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   681
    "Continue after the handle:do: - the handle:do: returns aBlock value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   682
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   683
    handlerContext unwindThenDo:aBlock
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   684
!
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   685
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   686
returnWith:value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   687
    "Continue after the handle:do: - the handle:do: returns value"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   688
2509
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   689
    |con|
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   690
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   691
    con := handlerContext.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   692
    resumeBlock := rejectBlock := handlerContext := suspendedContext := nil.
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   693
    con unwind:value
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   694
20e70b07473a clean out exceptions block & context references when
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   695
    "Modified: 27.3.1997 / 16:46:51 / cg"
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   696
! !
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   697
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   698
!Exception methodsFor:'raising'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   699
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   700
doCallHandler:aHandler
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   701
    "call the handler proper - needed an extra method
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   702
     to have a separate returnContext for the rejectBlock.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   703
     (which is historical, and actually no longer needed)"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   704
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   705
    |val|
362
claus
parents: 345
diff changeset
   706
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   707
    rejectBlock := [^ self]. "this will return on reject"
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   708
    val := aHandler value:self.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   709
    "
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   710
     handler fall through - is just like a returnWith:blocks-value
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   711
    "
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   712
    rejectBlock := nil.
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   713
    self returnWith:val
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   714
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   715
1378
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   716
doRaise
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   717
    "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
   718
     to the raising signal, a parent of it, or a SignalSet which includes 
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   719
     the raising signal.
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   720
     If found, take the contexts 2nd argument (the handler) and evaluate
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   721
     it with the receiver exception as argument.
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   722
     If no handler is found, try per signal handler, or
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   723
     per process handler (if its the noHandlerSignal).
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   724
     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
   725
     available and enters the debugger.
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   726
     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
   727
     #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
   728
2562
e89b40632edc removed unused var
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   729
    |theContext block noHandlerSignal any msg conArg1
1710
40f0539852ea *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
   730
     theSignal c ex1 activeHandlers inHandler rejected
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   731
     lastHandler h raiseReceiver r firstHandler|
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   732
3100
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   733
    theSignal := signal.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   734
    theSignal isSignal ifFalse:[
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   735
        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
   736
    ].
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   737
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   738
"/ '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
   739
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   740
    inHandler := false.
3100
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   741
    c := thisContext sender sender.    "the raise/raiseRequest-context"
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   742
                                       "the signal raise context"
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   743
2204
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   744
    "/ since the exceptionHandler is evaluated onTop of the
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   745
    "/ contextChain, we must skip active handlers before searching.
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   746
    "/ otherwise, we get into trouble, when re-raising an exception
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   747
    "/ from within a handler (which would lead to re-executing the
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   748
    "/ same handler)
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   749
    "/ the code below collects active handlers ...
0ec2bd49dd82 comment
Claus Gittinger <cg@exept.de>
parents: 2174
diff changeset
   750
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   751
    "/ on the fly, look for the first #handle:do: - context,
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   752
    "/ and remember it (as firstHandler) to avoid walking the context chain twice
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   753
    "/ in most cases ...
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   754
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   755
    firstHandler := nil.
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   756
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   757
    [c notNil] whileTrue:[
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   758
        firstHandler isNil ifTrue:[
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   759
            c := c findNextContextWithSelector:#doRaise or:#'handle:do:' or:#'handle:from:do:'.
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   760
        ] ifFalse:[
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   761
            c := c findNextContextWithSelector:#doRaise or:nil or:nil.
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   762
        ].
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   763
        c notNil ifTrue:[
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   764
            (c selector == #doRaise) ifTrue:[
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   765
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   766
                ex1 := c receiver.
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   767
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   768
                ((ex1 class == self class)
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   769
                or:[ex1 species == self species]) ifTrue:[
3110
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   770
		    (ex1 signal == theSignal) ifTrue:[
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   771
                        h := ex1 handlerContext.
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   772
                        h notNil ifTrue:[
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   773
                            r := h receiver.
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   774
                            (r notNil and:[r accepts:theSignal]) ifTrue:[
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   775
                                activeHandlers isNil ifTrue:[
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   776
                                    activeHandlers := OrderedCollection new
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   777
                                ].
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   778
3110
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   779
                                lastHandler := h.
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   780
                                activeHandlers add:lastHandler.
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   781
                                inHandler := true.
9a1e3a736e14 better handler search
Claus Gittinger <cg@exept.de>
parents: 3100
diff changeset
   782
                                c := lastHandler.
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   783
                            ]
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   784
                        ]
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   785
                    ]
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   786
                ]
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   787
            ] ifFalse:[
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   788
                "/ must be a #handle:do context ...
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   789
                firstHandler := c.
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   790
            ]
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   791
        ]
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   792
    ].
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   793
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   794
    "/ now, start searching for a handler,
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   795
    "/ start search above the last active handler.
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   796
    "/ Or start with the first handle:do: context, if one
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   797
    "/ was found as a side effect of the previous handler search.
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   798
    "/ If nil, then there is no handler and we can directly proceed
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   799
    "/ to the unhandled code below.
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   800
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   801
    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
   802
        theContext := lastHandler.
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   803
        theContext := lastHandler findNextContextWithSelector:#'handle:do:' or:#'handle:from:do:' or:nil.
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   804
    ] ifFalse:[
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   805
        theContext := firstHandler
1609
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   806
    ].
21f69f2adef7 when skipping active handlers, must not only look for
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
   807
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   808
    "/ remember if there was any handler
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   809
    "/ for the better errorString (unhandled vs. rejected exception)
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   810
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   811
    any := false.
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   812
    [theContext notNil] whileTrue:[
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   813
        (theContext selector == #'handle:do:'
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   814
        or:[(theContext argAt:2) == originator]) 
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   815
        ifTrue:[
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   816
            (activeHandlers notNil
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   817
             and:[activeHandlers includesIdentical:theContext]) ifTrue:[
3068
e022c6c4e588 removed debugPrint
Claus Gittinger <cg@exept.de>
parents: 3066
diff changeset
   818
"/                'skip activeHandler: ' print. theContext displayString printCR.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   819
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   820
            ] ifFalse:[
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   821
                "
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   822
                 if this is the Signal>>handle:do: context
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   823
                 or a SignalSet>>handle:do: context with self in it,
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   824
                 call the handler
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   825
                "
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   826
                r := theContext receiver.
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   827
                (r notNil and:[r accepts:signal]) ifTrue:[
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   828
                    "call the handler"
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   829
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   830
                    conArg1 := theContext argAt:1.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   831
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   832
                    handlerContext := theContext.
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   833
                    any := true.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   834
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   835
                    self doCallHandler:conArg1.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   836
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   837
                    "/ if the handler rejects, we arrive here
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   838
                    "/ continue search for another handler
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   839
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   840
                    rejected := true.
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   841
                ].
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2282
diff changeset
   842
            ]
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   843
        ].
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   844
        theContext := theContext findNextContextWithSelector:#'handle:do:' or:#'handle:from:do:' or:nil.
1482
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   845
    ].
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   846
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   847
    activeHandlers := nil.
f4b65def90e1 oops - correctly look for handlers when exceptions
Claus Gittinger <cg@exept.de>
parents: 1378
diff changeset
   848
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   849
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   850
     we arrive here, if either no handler was found, or none of the
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   851
     handlers did a return (i.e. every handler rejected or fell through).
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   852
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   853
    "
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   854
     try per signal handler
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   855
    "
1038
ab459e9eecc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   856
    (block := signal handlerBlock) isNil ifTrue:[
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   857
        "/
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   858
        "/ if its a querySignal, ignore it
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
        signal isQuerySignal ifTrue:[^ nil].
1118
1037616d9add ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
   861
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   862
        "/
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   863
        "/ if it is not the NoHandlerSignal, raise it ...
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   864
        "/ passing the receiver as parameter.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   865
        "/
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   866
        signal ~~ (noHandlerSignal := Signal noHandlerSignal) ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   867
            noHandlerSignal notNil ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   868
                any ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   869
                    msg := 'unhandled (rejected)'
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   870
                ] ifFalse:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   871
                    msg := 'unhandled'
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   872
                ].
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   873
                msg := msg , ' exception: (' , errorString , ')'.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   874
                ^ noHandlerSignal 
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   875
                      raiseRequestWith:self 
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   876
                           errorString:msg
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   877
                                    in:self suspendedContext
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   878
            ].
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   879
            "/
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   880
            "/ mhmh - an error during early startup; noHandlerSignal is
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   881
            "/ not yet defined.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   882
            "/
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   883
            ^ MiniDebugger enterWithMessage:errorString
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   884
        ].
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   885
2282
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   886
        "
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   887
         mhmh - smells like trouble - there is no handler and
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   888
         no per-signal handler block.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   889
         Look for either a per-process emergencyHandlerBlock 
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   890
         or the global emergencyHandler (from Exception) ...
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   891
        "
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   892
        Processor notNil ifTrue:[ 
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   893
            "care for signal during startup (Processor not yet created)"
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   894
            block := Processor activeProcess emergencySignalHandler.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   895
        ].
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   896
        block isNil ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   897
            block := Exception emergencyHandler.
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   898
            block isNil ifTrue:[
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   899
                "care for error during startup (Exception not yet initialized)"
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   900
                ^ MiniDebugger enterWithMessage:errorString
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   901
            ].
e019b9fb2977 fast search for handler
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   902
        ].
171
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   903
    ].
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   904
    "... and call it"
129f0e2e23df handling now in Exception
claus
parents: 142
diff changeset
   905
    ^ block value:self.
1118
1037616d9add ignore unhandled querySignals
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
   906
3066
eb7489e8275a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3017
diff changeset
   907
    "Created: / 12.5.1996 / 15:09:39 / cg"
3100
c96f3b203a60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   908
    "Modified: / 9.11.1997 / 14:48:44 / cg"
1378
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   909
!
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   910
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   911
raise
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   912
    "actually raise a non-proceedable exception.
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   913
     CAVEAT:
2208
cc55b9f5b47e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   914
	 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
   915
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   916
    resumeBlock := [:value | ^ value].
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   917
    ^ self doRaise
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   918
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   919
    "Modified: 12.5.1996 / 15:09:47 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   920
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   921
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   922
raiseRequest
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   923
    "actually raise a proceedable exception."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   924
1378
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   925
    resumeBlock := [:value | ^ value].
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   926
    ^ self doRaise
1376
6757590defbf avoid extra send (raise->evaluateHandler)
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   927
1378
056b3a0928f2 oops - the last one was bogus
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   928
    "Modified: 12.5.1996 / 15:09:44 / cg"
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   929
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   930
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   931
!Exception methodsFor:'setup'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   932
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   933
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   934
    "set the fields usable for inspection by the handler
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   935
     - only to be sent from the signal when raising"
328
claus
parents: 326
diff changeset
   936
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   937
    signal := aSignal.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   938
    parameter := aParameter.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   939
    errorString := aString.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   940
    suspendedContext := sContext.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   941
    originator := origin.
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   942
! !
328
claus
parents: 326
diff changeset
   943
1953
c8a3af54acb3 unhandled querySignals should return nil
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   944
!Exception class methodsFor:'documentation'!
662
df7953db3847 version method at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   945
df7953db3847 version method at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   946
version
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3110
diff changeset
   947
    ^ '$Header: /cvs/stx/stx/libbasic/Exception.st,v 1.62 1997-11-15 14:06:12 cg Exp $'
662
df7953db3847 version method at the end
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   948
! !
621
87602c9d071c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 547
diff changeset
   949
Exception initialize!