GenericException.st
author Stefan Vogel <sv@exept.de>
Thu, 12 Aug 2004 17:48:55 +0200
changeset 8472 5e8d452b5d75
parent 8466 ce104835047e
child 8487 5c9ffa3553e3
permissions -rw-r--r--
Mark methods as private
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
     3
	      All Rights Reserved
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
5348
8220f8db1cc1 added #signalWith: for ANSI compatibility.
Claus Gittinger <cg@exept.de>
parents: 5295
diff changeset
    13
"{ Package: 'stx:libbasic' }"
8220f8db1cc1 added #signalWith: for ANSI compatibility.
Claus Gittinger <cg@exept.de>
parents: 5295
diff changeset
    14
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
Object subclass:#GenericException
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
    16
	instanceVariableNames:'signal parameter messageText suspendedContext handlerContext
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
    17
		rejected originator proceedable handlingException'
6264
250dea266e37 no longer raise WrongProceedabilityError - it pisses me off
Claus Gittinger <cg@exept.de>
parents: 6250
diff changeset
    18
	classVariableNames:'StrictRaising'
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
    19
	poolDictionaries:''
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
    20
	category:'Kernel-Exceptions'
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
GenericException class instanceVariableNames:'NotifierString'
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
"
5259
cda0ce95054d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5197
diff changeset
    26
 No other class instance variables are inherited by this class.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
!GenericException class methodsFor:'documentation'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
copyright
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 COPYRIGHT (c) 1993 by Claus Gittinger
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    35
	      All Rights Reserved
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 This software is furnished under a license and may be used
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 only in accordance with the terms of that license and with the
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 inclusion of the above copyright notice.   This software may not
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 be provided or otherwise made available to, or used by, any
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
 other person.  No title to or ownership of the software is
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
 hereby transferred.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
documentation
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
"
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
    48
    Note: 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    49
	The instance based Signal framework is being replaced by
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    50
	class based exceptions.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    51
	I.e. what used to be instances of Signal/QuerySignal is beeing
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    52
	rewritten into subclasses of Exception/Error/Query and Warning.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    53
	Although the functionality is basically unchanged, the new
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    54
	class based exceptions are easier to instanciate (no need for
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    55
	creation in a classes initialize method), easier to use (no real
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    56
	need for SIgnal-constant accessors) and allow for easier parameter
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    57
	passing (not only a single parameter, but allows for individual
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    58
	exception subclasses to add additional state).
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
    59
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    GenericException and its subclasses implement the same protocol as Signal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    So class based exceptions may be implemented as subclasses of GenericException.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
7631
df27883aa7db Undo previous change form cg (on his request!).
Stefan Vogel <sv@exept.de>
parents: 7597
diff changeset
    63
    Normally all exceptions are subclasses of Exception. Exceptions, that are
df27883aa7db Undo previous change form cg (on his request!).
Stefan Vogel <sv@exept.de>
parents: 7597
diff changeset
    64
    used for debugging or that are signalling errors in the exception system itself
df27883aa7db Undo previous change form cg (on his request!).
Stefan Vogel <sv@exept.de>
parents: 7597
diff changeset
    65
    are direct subclasses of GenericException.
df27883aa7db Undo previous change form cg (on his request!).
Stefan Vogel <sv@exept.de>
parents: 7597
diff changeset
    66
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    Instances of Exception are passed to a Signal handling block as argument.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    The handler block may perform various actions by sending corresponding messages
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    to the exception object. The following actions are possible:
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    71
	reject          - don't handle this signal;
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    72
			  another handler will be searched for, 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    73
			  upper in the calling hierarchy
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    74
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    75
	proceed         - return from the Signal>>raise, with nil as value
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    76
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    77
	proceedWith:val - same, but return val from Signal>>raise
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    78
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    79
	return          - return from the Signal>>handle:do:, with nil as value
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    80
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    81
	returnWith:val  - same, but return val from Signal>>handle:do:
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    82
			  (this is also the handlers default, 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    83
			   if it falls through; taking the handlerBlocks value
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    84
			   as return value)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    85
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    86
	restart         - restart the Signal>>handle:do:, after repairing
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    Via the Exception object, the handler can also query the state of execution:
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    where the Signal was raised, where the handler is, the signal which caused
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
    90
    the error and the messageText passed when the signal was raised. Also, an optional
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    parameter can be passed - the use is signal specific.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    [instance variables:]
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    94
	signal           <Signal>     the signal which caused the exception
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    95
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    96
	parameter        <Object>     a parameter (if any) which was passed when raising
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    97
				      the signal (only if raised with #raiseWith:aParameter)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
    98
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
    99
	messageText      <String>     an messageText 
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   100
				      (usually the signals own messageText, but sometimes
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   101
				       changed explicitely in #raiseWith:errorString:)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   102
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   103
	suspendedContext <Context>    the context in which the raise occured
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   104
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   105
	handlerContext   <Context>    the context of the handler (if any)
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    In case of an unhandled signal raise, Exceptions EmergenyHandler will be evaluated. 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    The default emergeny handler will enter the debugger.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    For applications, which do not want Debuggers to come up, other handlers are
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    possible.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    For example, to get the typical C++ behavior, use:
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   113
	Exception emergencyHandler:[:ex | Smalltalk exitWithCoreDump]
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   115
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   116
    Raising:
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   117
	two different raising messages are to be used, 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   118
	depending on whether the exception is proceedable or not
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   119
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   120
	For some stupid reason, someone decided that the raise-code checks if
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   121
	the raising messages matches to what the signal thinks is its proceedability.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   122
	(i.e. not only do both the sender and the signal itself specify proceedability,
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   123
	 this is checked by the raise code and a warning is generated if there is a mismatch)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   124
	This used to be even worse (WrongProceedabilityError), but we relaxed this to
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   125
	a message sent to stderr.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   126
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   127
	That means, that PROCEEDABLE signals must be raised with:
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   128
	    raiseRequest
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   129
	and NON-PROCEEDABLE signals must be raised with:
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   130
	    raise
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   131
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   132
	If you dont know/care as a raiser, you can use
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   133
	    raiseSignal
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   134
	which checks for proceedability and sends the appropriate message.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   135
	(sigh)
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   136
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   137
    all of the 3 messages above come in various flavours:
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   138
	raiseXXX                - do not pass any additional parameter;
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   139
				  default messageText
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   140
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   141
	raiseXXXWith:           - pass additional parameter;
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   142
				  default messageText
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   143
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   144
	raiseXXXErrorString:    - do not pass any additional parameter;
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   145
				  given errorString
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   146
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   147
	raiseXXXWith:errorString:
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   148
				- pass any additional parameter;
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   149
				  AND given errorString
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   150
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   151
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    [see also:]
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   153
	Signal  SignalSet QuerySignal
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   154
	Context Block
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   155
	Object DebugView
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   156
	(``Exception handling and signals'': programming/exceptions.html)
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    [author:]
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   159
	Claus Gittinger
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
examples
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    Examples on Exception-raising & handling are found in the doc/coding
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    section (CodingExamples).
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    The emergencyHandler stuff is very useful, to prevent endUser applications
4554
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4548
diff changeset
   169
    from entering the debugger. See the examples in NoHandlerError.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
!GenericException class methodsFor:'initialization'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
initialize 
4519
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   176
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   177
    NotifierString := 'unknown exception'.
6598
6d5c36971981 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6581
diff changeset
   178
    StrictRaising := false.     "set to true to check weather a signal may be raised proceedable"
4519
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   179
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   180
    "Modified: / 4.8.1999 / 09:06:26 / stefan"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
!GenericException class methodsFor:'instance creation'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
signal:aSignal originator:origin
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    "create a new instance and set the fields in preparation for a raise.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
     - only to be sent from the signal when raising"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
    "{ Pragma: +inlineNew }"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    ^ (self basicNew) signal:aSignal originator:origin.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    "Created: / 23.7.1999 / 13:40:45 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
    "create a new instance and set the fields in preparation for a raise.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
     - only to be sent from the signal when raising"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    "{ Pragma: +inlineNew }"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    ^ (self basicNew)
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   203
	signal:aSignal 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   204
	parameter:aParameter 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   205
	errorString:aString 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   206
	suspendedContext:sContext 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   207
	originator:origin.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
7296
2b8a6ee9a1cf category
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   210
!GenericException class methodsFor:'Compatibility-ANSI'!
5348
8220f8db1cc1 added #signalWith: for ANSI compatibility.
Claus Gittinger <cg@exept.de>
parents: 5295
diff changeset
   211
8466
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   212
raiseSignal:errorMessage 
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   213
    "raise a signal (proceedable or not, whatever the proceedability is).
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   214
     The argument, errorMessage is used as messageText."
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   215
    
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   216
    <context: #return>
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   217
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   218
    ^ (self newException 
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   219
        suspendedContext:thisContext sender
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   220
        errorString:errorMessage) raiseSignal.
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   221
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   222
    "Modified: / 07-08-2004 / 19:24:00 / stefan"
5697
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   223
!
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   224
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   225
raiseSignal:errorMessage with:aParameter
8466
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   226
    "raise a signal (proceedable or not, whatever the proceedability is).
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   227
     The argument, errorMessage is used as messageText."
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   228
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   229
    <context: #return>
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   230
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   231
    ^ (self newException 
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   232
        suspendedContext:thisContext sender
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   233
        errorString:errorMessage;
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   234
        parameter:aParameter)
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   235
            raiseSignal.
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   236
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
   237
    "Modified: / 07-08-2004 / 19:10:40 / stefan"
5697
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   238
!
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   239
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   240
signalWith:messageText
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   241
    self raiseErrorString:messageText
5348
8220f8db1cc1 added #signalWith: for ANSI compatibility.
Claus Gittinger <cg@exept.de>
parents: 5295
diff changeset
   242
! !
8220f8db1cc1 added #signalWith: for ANSI compatibility.
Claus Gittinger <cg@exept.de>
parents: 5295
diff changeset
   243
7296
2b8a6ee9a1cf category
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   244
!GenericException class methodsFor:'Compatibility-Dolphin'!
6246
3a9ed5550ef8 dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 6220
diff changeset
   245
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   246
signal:messageText
6250
b2713bc931eb dolphin
Claus Gittinger <cg@exept.de>
parents: 6248
diff changeset
   247
    "raise a signal proceedable or nonproceedable (whichever is right).
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   248
     The argument is used as messageText."
6250
b2713bc931eb dolphin
Claus Gittinger <cg@exept.de>
parents: 6248
diff changeset
   249
b2713bc931eb dolphin
Claus Gittinger <cg@exept.de>
parents: 6248
diff changeset
   250
    <context: #return>
b2713bc931eb dolphin
Claus Gittinger <cg@exept.de>
parents: 6248
diff changeset
   251
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   252
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   253
	suspendedContext:thisContext sender
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   254
	errorString:messageText)
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   255
	    raiseSignal.
6246
3a9ed5550ef8 dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 6220
diff changeset
   256
! !
3a9ed5550ef8 dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 6220
diff changeset
   257
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
!GenericException class methodsFor:'Signal constants'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
4517
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   260
noHandlerError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   261
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   262
    ^ NoHandlerError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   263
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   264
    "Created: / 4.8.1999 / 08:33:35 / stefan"
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   265
!
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   266
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   267
proceedError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   268
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   269
    ^ ProceedError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   270
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   271
    "Created: / 4.8.1999 / 08:34:30 / stefan"
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   272
!
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   273
4519
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   274
recursiveExceptionError
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    "return the signal used to handle recursive signals in the handlers"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
4519
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   277
    ^ RecursiveExceptionError
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   278
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   279
    "Created: / 4.8.1999 / 09:05:06 / stefan"
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   280
!
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   281
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   282
recursiveExceptionSignal
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   283
    "return the signal used to handle recursive signals in the handlers.
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   284
     This is for backward compatinility. Use recursiveExceptionError"
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   285
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   286
    ^ RecursiveExceptionError
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   287
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   288
    "Modified: / 4.8.1999 / 09:05:59 / stefan"
4517
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   289
!
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   290
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   291
wrongProceedabilityError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   292
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   293
    ^ WrongProceedabilityError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   294
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   295
    "Created: / 4.8.1999 / 08:34:19 / stefan"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   298
!GenericException class methodsFor:'accessing'!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   299
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   300
notifierString:aString
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   301
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   302
    NotifierString := aString
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   303
! !
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   304
7296
2b8a6ee9a1cf category
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   305
!GenericException class methodsFor:'compatibility-accessing'!
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
errorString
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   308
    "#errorString is deprecated, use description instead"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
6859
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
   310
    <resource:#obsolete>
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
   311
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   312
    ^ self description
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
handlerBlock
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
    "Compatibility with Signal. Class based exeptions do not have a handler
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
     block. They redefine the #action method instead"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    ^ nil
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
    "Created: / 23.7.1999 / 14:43:18 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
    "Modified: / 24.7.1999 / 20:52:10 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
7296
2b8a6ee9a1cf category
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   325
!GenericException class methodsFor:'compatibility-defaults'!
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   326
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   327
emergencyHandler
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   328
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   329
    ^ NoHandlerError emergencyHandler.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   330
!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   331
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   332
emergencyHandler:aOneArgBlock
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   333
    "set the handler used for unhandled exceptions.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   334
     The default (a nil-handler) leads to a debugger to be shown."
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   335
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   336
    ^ NoHandlerError emergencyHandler:aOneArgBlock.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   337
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   338
    "ST-80 behavior of first showing a notifier:
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   339
     (I prefer to get right into the debugger, though)
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   340
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   341
     Exception
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   342
	emergencyHandler:
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   343
	    [:ex | self errorNotify:ex description ]
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   344
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   345
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   346
    "ST-X behavior of going right into the debugger:
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   347
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   348
     Exception
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   349
	emergencyHandler:nil
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   350
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   351
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   352
    "automatically aborting current operation, on error:
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   353
     (may be useful for end-user apps; make certain, 
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   354
      you have abortSignal handlers at appropriate places)
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   355
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   356
     Exception
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   357
	emergencyHandler:
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   358
	    [:ex | Object abortSignal raise. ex return. ]
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   359
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   360
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   361
    "finally, traditional language system behavior; dump core ;-)
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   362
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   363
     Exception
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   364
	emergencyHandler:
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   365
	    [:ex | Smalltalk exitWithCoreDump. ]
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   366
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   367
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   368
    "Modified: 15.1.1997 / 20:49:06 / cg"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   369
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   370
! !
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   371
7296
2b8a6ee9a1cf category
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   372
!GenericException class methodsFor:'compatibility-queries'!
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
accepts:aSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
    "return true, if the receiver accepts the argument, aSignal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
     (i.e. the receiver is aSignal or a parent of it). False otherwise."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    |s|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
4527
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4521
diff changeset
   380
    self == aSignal ifTrue:[^ true].
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
    aSignal isQuerySignal ifTrue:[^ false].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
    s := aSignal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
    [s notNil] whileTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   385
	self == s ifTrue:[^ true].
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   386
	s := s parent
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
    ^ false
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
    "Created: / 23.7.1999 / 14:00:47 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   393
exception:anExceptionHandler isHandledIn:aContext
4676
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   394
    "return true, if there is a handler for the receiver signal in the 
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   395
     contextChain starting with aContext."
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   396
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   397
    |theContext|
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   398
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   399
    theContext := aContext findExceptional.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   400
    [theContext notNil] whileTrue:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   401
        theContext isRaiseContext ifTrue:[ |ex1 con1|
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   402
            "skip all the contexts between the raise and the sender of #handle:do"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   403
            ex1 := theContext receiver.              "exception, that has been raised"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   404
            con1 := ex1 handlerContext.              "the context of the #handle:do:"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   405
            con1 notNil ifTrue:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   406
                "handlerContext may be nil, if this is a default action"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   407
                theContext := con1.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   408
            ].
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   409
            ex1 := con1 := nil.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   410
        ] ifFalse:[ |r|
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   411
            ((r := theContext receiver) notNil
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   412
             and:[(r handlerForSignal:anExceptionHandler context:theContext originator:nil) notNil]
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   413
            ) ifTrue:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   414
                "found a handler context"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   415
                ^ true
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   416
            ].
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   417
        ].
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   418
        theContext notNil ifTrue:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   419
            theContext := theContext findSpecialHandle:true raise:true.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   420
        ].
4676
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   421
    ].
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   422
4676
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   423
    ^ false
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   424
!
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   425
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
handlerForSignal:signal context:theContext originator:originator
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
    "answer the handler block for the signal from originator.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
     The block is retrieved from aContext.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
     Answer nil if the signal is not handled"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
    (theContext selector ~~ #'handle:from:do:'
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
     or:[(theContext argAt:2) == originator]) ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   434
	(self == signal or:[self accepts:signal]) ifTrue:[
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   435
	    ^ theContext argAt:1
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   436
	]
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
    ^ nil
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
    "Created: / 25.7.1999 / 19:52:58 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   444
handlerProtectedBlock:doBlock inContext:context
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   445
    "set the handlerProtectedBlock in context"
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   446
5590
e85d241c7a36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5570
diff changeset
   447
    |sel|
e85d241c7a36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5570
diff changeset
   448
e85d241c7a36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5570
diff changeset
   449
    sel := context selector.
e85d241c7a36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5570
diff changeset
   450
    sel == #handle:do: ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   451
	context argAt:2 put:doBlock.
5590
e85d241c7a36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5570
diff changeset
   452
    ] ifFalse:[sel == #handle:from:do: ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   453
	context argAt:3 put:doBlock.
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   454
    ]].
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   455
!
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   456
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
handlingExceptionInContext:theContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
    "answer the handling exception from aContext."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
5590
e85d241c7a36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5570
diff changeset
   460
    |sel|
e85d241c7a36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5570
diff changeset
   461
e85d241c7a36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5570
diff changeset
   462
    sel := theContext selector.
e85d241c7a36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5570
diff changeset
   463
    (sel == #'handle:from:do:'
e85d241c7a36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5570
diff changeset
   464
     or:[sel == #'handle:do:']) ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   465
	^ theContext receiver
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
    ^ nil
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
inheritsFrom:anotherSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
    "return true, if the receiver is a child of anotherSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
     (i.e. if handling anotherSignal also handles the receiver)
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
     This is almost the same as accepts, but returns false, if
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
     the receiver is identical to anotherSignal."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
    self == anotherSignal ifTrue:[^ false].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
    ^ anotherSignal accepts:self
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
    "Created: / 23.7.1999 / 13:59:51 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
6630
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   483
isExceptionCreator
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   484
    "return true, if the receiver can create exceptions,
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   485
     this includes #raise, #raiseRequest as well as the behavior of
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   486
     an exception handler, such as the #accepts: and #handles: messages"
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   487
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   488
    ^ true
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   489
!
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   490
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   491
isExceptionHandler
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   492
    "return true, if the receiver responds to the exception handler protocol,
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   493
     especially to the #accepts: and #handles: messages"
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   494
6630
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   495
    ^ true
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   496
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   497
    "Created: / 23.7.1999 / 13:49:59 / stefan"
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   498
!
0f6ecb272b09 #isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents: 6598
diff changeset
   499
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
isHandled
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
    "return true, if there is a handler for the receiver signal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
     Raising an unhandled signal will usually lead into the debugger,
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
     but can be caught globally by setting Exceptions EmergencyHandler."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
4676
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   505
    ^ self exception:self isHandledIn:(thisContext sender).
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
    "Created: / 23.7.1999 / 14:03:50 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
isHandledIn:aContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
    "return true, if there is a handler for the receiver signal in the 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
     contextChain starting with aContext."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
4676
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   514
    ^ self exception:self isHandledIn:aContext
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
isQuerySignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
    "return true, if this is a querySignal - always return false here"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
    ^ false
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
    "Created: / 23.7.1999 / 13:50:16 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
mayProceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
    "return true, if the exception handler is allowed to proceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
     the execution where the exception occured.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
     Subclasses may redefine this."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
    ^ true
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
    "Modified: / 23.7.1999 / 14:50:11 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
parent
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
    "return the parent Signal/Exception of myself.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
     Subclasses may redefine this to install themself as child of
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
     existing Signals."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
    self == GenericException ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   542
	^ nil
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
    ^ self superclass
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
    "Created: / 23.7.1999 / 14:01:29 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
    "Modified: / 23.7.1999 / 16:15:38 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
7296
2b8a6ee9a1cf category
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   551
!GenericException class methodsFor:'compatibility-raising'!
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
new
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   554
    "{ Pragma: +inlineNew }"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
6945
9536335d243b use setSignal, to avoid conflict with dolphin signals
Claus Gittinger <cg@exept.de>
parents: 6920
diff changeset
   556
    ^ self basicNew setSignal:self.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
    "Modified: / 23.7.1999 / 13:53:12 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
    "Created: / 24.7.1999 / 13:21:13 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
newException
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
    ^ self new
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
    "Created: / 23.7.1999 / 13:45:49 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
    "Modified: / 24.7.1999 / 13:21:25 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
newExceptionFrom:originator
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
    "answer a new exception object for this signal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
     Set the originator.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
     Subclasses may redefine this method"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
    ^ self new originator:originator
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
    "Created: / 23.7.1999 / 13:47:07 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
raise
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
    "raise a signal nonproceedable.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   582
     The signals notifierString is used as messageText."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   584
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   585
4538
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   586
    ^ self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   587
	suspendedContext:thisContext sender;
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   588
	raise
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
    "Modified: / 2.5.1996 / 16:36:23 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
    "Modified: / 5.3.1998 / 16:44:36 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
    "Created: / 23.7.1999 / 14:07:17 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
raiseErrorString:aString
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
    "raise a signal nonproceedable.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   597
     The argument is used as messageText."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   599
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   600
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   601
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   602
	suspendedContext:thisContext sender
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   603
	errorString:aString)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   604
	    raise.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
    "Modified: / 9.5.1996 / 15:17:59 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
    "Modified: / 12.3.1998 / 15:15:22 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
    "Created: / 23.7.1999 / 14:07:33 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
5684
53cc1d686f03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5680
diff changeset
   611
raiseErrorString:aString in:aContext
53cc1d686f03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5680
diff changeset
   612
    "raise a signal nonproceedable.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   613
     The argument is used as messageText."
5684
53cc1d686f03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5680
diff changeset
   614
53cc1d686f03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5680
diff changeset
   615
    <context: #return>
53cc1d686f03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5680
diff changeset
   616
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   617
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   618
	suspendedContext:aContext
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   619
	errorString:aString)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   620
	    raise.
5684
53cc1d686f03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5680
diff changeset
   621
53cc1d686f03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5680
diff changeset
   622
    "Modified: / 9.5.1996 / 15:17:59 / cg"
53cc1d686f03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5680
diff changeset
   623
    "Modified: / 12.3.1998 / 15:15:22 / stefan"
53cc1d686f03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5680
diff changeset
   624
    "Created: / 23.7.1999 / 14:07:33 / stefan"
53cc1d686f03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5680
diff changeset
   625
!
53cc1d686f03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5680
diff changeset
   626
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
raiseFrom:something
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
    "raise a signal nonproceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
     The argument, something is passed both as parameter and originator."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   631
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   632
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   633
    ^ ((self newExceptionFrom:something) 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   634
	suspendedContext:thisContext sender
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   635
	parameter:something)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   636
	    raise
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
    "Modified: / 2.5.1996 / 16:36:38 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
    "Modified: / 5.3.1998 / 16:49:55 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
    "Created: / 23.7.1999 / 14:07:59 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
raiseRequest
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
    "raise a signal proceedable.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   645
     The signals notifierString is used as messageText."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   647
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   648
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   649
    ^ self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   650
	suspendedContext:thisContext sender;
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   651
	raiseRequest.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
    "Modified: / 2.5.1996 / 16:36:52 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
    "Modified: / 5.3.1998 / 16:50:46 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
    "Created: / 23.7.1999 / 14:08:24 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
4758
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   658
raiseRequestErrorString:aString
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   659
    "raise a signal proceedable.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   660
     The argument, aString is used as messageText."
4758
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   661
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   662
    <context: #return>
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   663
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   664
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   665
	suspendedContext:thisContext sender
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   666
	errorString:aString)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   667
	    raiseRequest
4758
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   668
!
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   669
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   670
raiseRequestFrom:something
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
    "raise a signal proceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
     The argument, something is passed both as parameter and originator."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   674
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   675
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   676
    ^ ((self newExceptionFrom:something) 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   677
	suspendedContext:thisContext sender
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   678
	parameter:something)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   679
	    raiseRequest.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
    "Modified: / 2.5.1996 / 16:36:38 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
    "Modified: / 5.3.1998 / 16:52:46 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
    "Created: / 23.7.1999 / 14:08:36 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
raiseRequestWith:aParameter
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
    "raise a signal proceedable.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   688
     The signals notifierString is used as messageText."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   690
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   691
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   692
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   693
	suspendedContext:thisContext sender
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   694
	parameter:aParameter)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   695
	    raiseRequest.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   697
    "Modified: / 9.5.1996 / 15:13:20 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
    "Modified: / 12.3.1998 / 15:16:57 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
    "Created: / 23.7.1999 / 14:08:48 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
raiseRequestWith:aParameter errorString:aString
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
    "raise a signal proceedable.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   704
     The argument, aString is used as messageText."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   706
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   707
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   708
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   709
	suspendedContext:thisContext sender
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   710
	parameter:aParameter  
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   711
	errorString:aString)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   712
	    raiseRequest
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
    "Modified: / 9.5.1996 / 15:13:35 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
    "Modified: / 12.3.1998 / 15:17:52 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
    "Created: / 23.7.1999 / 14:08:57 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
raiseRequestWith:aParameter errorString:aString in:aContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
    "raise a signal proceedable.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   721
     The argument, aString is used as messageText.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
     The additional context is passed as the context responsible for the raise,
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
     allowing a raise to mimicri the exception happened somewhere else."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   725
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   726
	suspendedContext:aContext
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   727
	parameter:aParameter  
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   728
	errorString:aString)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   729
	    raiseRequest
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   730
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
    "Modified: / 26.7.1996 / 16:29:27 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
    "Modified: / 12.3.1998 / 15:18:34 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
    "Created: / 23.7.1999 / 14:09:07 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
5259
cda0ce95054d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5197
diff changeset
   736
raiseRequestWith:aParameter in:aContext
cda0ce95054d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5197
diff changeset
   737
    "raise a signal proceedable.
cda0ce95054d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5197
diff changeset
   738
     The additional context is passed as the context responsible for the raise,
cda0ce95054d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5197
diff changeset
   739
     allowing a raise to mimicri the exception happened somewhere else."
cda0ce95054d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5197
diff changeset
   740
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   741
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   742
	suspendedContext:aContext
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   743
	parameter:aParameter) 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   744
	    raiseRequest
5259
cda0ce95054d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5197
diff changeset
   745
!
cda0ce95054d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5197
diff changeset
   746
6174
4dd6c093ab6d +raiseSignal
Claus Gittinger <cg@exept.de>
parents: 6158
diff changeset
   747
raiseSignal
4dd6c093ab6d +raiseSignal
Claus Gittinger <cg@exept.de>
parents: 6158
diff changeset
   748
    "raise a signal (proceedable or not, whatever the proceedability is).
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   749
     The signals notifierString is used as messageText."
6174
4dd6c093ab6d +raiseSignal
Claus Gittinger <cg@exept.de>
parents: 6158
diff changeset
   750
4dd6c093ab6d +raiseSignal
Claus Gittinger <cg@exept.de>
parents: 6158
diff changeset
   751
    <context: #return>
4dd6c093ab6d +raiseSignal
Claus Gittinger <cg@exept.de>
parents: 6158
diff changeset
   752
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   753
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   754
	suspendedContext:thisContext sender)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   755
	    raiseSignal
6174
4dd6c093ab6d +raiseSignal
Claus Gittinger <cg@exept.de>
parents: 6158
diff changeset
   756
4dd6c093ab6d +raiseSignal
Claus Gittinger <cg@exept.de>
parents: 6158
diff changeset
   757
    "Modified: / 10.11.2001 / 15:13:34 / cg"
4dd6c093ab6d +raiseSignal
Claus Gittinger <cg@exept.de>
parents: 6158
diff changeset
   758
!
4dd6c093ab6d +raiseSignal
Claus Gittinger <cg@exept.de>
parents: 6158
diff changeset
   759
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   760
raiseSignalErrorString:aString
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   761
    "raise a signal (proceedable or not, whatever the proceedability is).
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   762
     The argument, aString is used as messageText."
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   763
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   764
    <context: #return>
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   765
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   766
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   767
	suspendedContext:thisContext sender
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   768
	errorString:aString)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   769
	    raiseSignal.
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   770
!
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   771
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   772
raiseSignalWith:aParameter
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   773
    "raise a signal (proceedable or not, whatever the proceedability is).
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   774
     The argument, aParameter is passed as parameter."
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   775
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   776
    <context: #return>
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   777
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   778
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   779
	suspendedContext:thisContext sender
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   780
	parameter:aParameter)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   781
	    raiseSignal.
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   782
!
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   783
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   784
raiseSignalWith:aParameter errorString:aString
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   785
    "raise a signal (proceedable or not, whatever the proceedability is).
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   786
     The argument, aString is used as messageText, 
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   787
     aParameter is passed as exception parameter."
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   788
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   789
    <context: #return>
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   790
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   791
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   792
	suspendedContext:thisContext sender
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   793
	parameter:aParameter
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   794
	errorString:aString)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   795
	    raiseSignal.
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   796
!
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   797
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
raiseWith:aParameter
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
    "raise a signal nonproceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
     The argument, aParameter is passed as parameter."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   802
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   803
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   804
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   805
	suspendedContext:thisContext sender
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   806
	parameter:aParameter)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   807
	    raise.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   809
    "Modified: / 9.5.1996 / 15:14:24 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
    "Modified: / 12.3.1998 / 15:19:11 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
    "Created: / 23.7.1999 / 14:09:27 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
raiseWith:aParameter errorString:aString
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
    "raise a signal nonproceedable.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   816
     The argument, aString is used as messageText, 
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   817
     aParameter is passed as exception parameter."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   819
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   820
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   821
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   822
	suspendedContext:thisContext sender
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   823
	parameter:aParameter
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   824
	errorString:aString)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   825
	    raise.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
    "Modified: / 9.5.1996 / 15:14:32 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
    "Modified: / 12.3.1998 / 15:19:40 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
    "Created: / 23.7.1999 / 14:09:36 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
raiseWith:aParameter errorString:aString in:aContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
    "raise a signal nonproceedable.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   834
     The argument, aString is used as messageText, aParameter is passed
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
     as exception parameter.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
     The additional context is passed as the context responsible for the raise,
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
     allowing a raise to mimicri the exception happened somewhere else."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   839
    ^ (self newException 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   840
	  suspendedContext:aContext 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   841
	  parameter:aParameter 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   842
	  errorString:aString)
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   843
	      raise.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
    "Modified: / 26.7.1996 / 16:29:42 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
    "Modified: / 12.3.1998 / 15:20:12 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
    "Created: / 23.7.1999 / 14:09:46 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
7296
2b8a6ee9a1cf category
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   850
!GenericException class methodsFor:'compatibility-save evaluation'!
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
catch:aBlock
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   853
    "evaluate the argument, aBlock.
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   854
     If the receiver-signal is raised during evaluation, abort
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   855
     the evaluation and return true; otherwise return false. 
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   856
     This is the catch & throw mechanism found in other languages,
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   857
     where the returned value indicates if an exception occured."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   859
    |raiseOccurred|
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   861
    raiseOccurred := false.
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   862
    self handle:[:ex | raiseOccurred := true. ex return] do:aBlock.
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   863
    ^ raiseOccurred
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   865
    "
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   866
     Object messageNotUnderstoodSignal catch:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   867
	123 size open   
6426
8b6a357addb6 comment change
Claus Gittinger <cg@exept.de>
parents: 6396
diff changeset
   868
     ]      
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   869
    "
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   871
    "Created: / 23.7.1999 / 14:06:01 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   872
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   873
6396
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   874
deferAfter:aBlock
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   875
    "evaluate the argument, aBlock.
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   876
     Ignore the receiver-signal during evaluation - i.e. simply continue,
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   877
     but remember if the signal was raised.
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   878
     After the block evaluation, finally raise the signal - if it was raised in the block.
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   879
     If the signal is raised multiple times, only the first raises parameter is remembered,
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   880
     and only a single raise is performed after the blocks evaluation.
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   881
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   882
     Deferring makes sense for some signals, such as UserInterrupt or AbortSignal, 
6426
8b6a357addb6 comment change
Claus Gittinger <cg@exept.de>
parents: 6396
diff changeset
   883
     which must occasionally be delayed temporarily until a save place is reached 
6396
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   884
     (especially when packages are sent across a communication channel, and you dont want
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   885
      partial packages to be generated by user interruptions)."
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   886
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   887
    |coughtException result|
6396
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   888
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   889
    self handle:[:ex |
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   890
	coughtException isNil ifTrue:[
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   891
	    coughtException := ex.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   892
	].
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   893
	ex proceedWith:nil
6396
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   894
    ] do:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   895
	result := aBlock value.
6396
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   896
    ].
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   897
    coughtException notNil ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   898
	coughtException suspendedContext:thisContext.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   899
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   900
	"/ the exception was raised during the execution of aBlock above. 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   901
	"/ Raise it now (delayed).
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   902
	coughtException raiseSignal.
6396
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   903
    ].
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   904
    ^ result
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   905
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   906
    "
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   907
     UserInterrupt deferAfter:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   908
	 Transcript showCR:'1 - now raising, but will be deferred.'.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   909
	 UserInterrupt raiseRequestWith:'hello'.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   910
	 Transcript showCR:'2 - after the raise, deferred exception will be handled soon.'.
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   911
     ].
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   912
     Transcript showCR:'3 - here after the protected block.'.
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
   913
    "
6396
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   914
!
74d5b0b588a6 added deferAfter: - defer exceptions until some later time
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   915
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   916
handle:handleBlock do:aBlock
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   917
    "evaluate the argument, aBlock.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   918
     If the receiver-signal is raised during evaluation,
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   919
     evaluate the handleBlock passing it an Exception argument.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   920
     The handler may decide how to react to the signal by sending
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
     a corresponding message to the exception (see there).
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   922
     If the signal is not raised, return the value of evaluating
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   923
     aBlock."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   924
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   925
    <context: #return>
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
   926
    <exception: #handle>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
   927
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   928
    "/ thisContext markForHandle. -- same as above pragma
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   929
    ^ aBlock value  "the real logic is in Exception>>doRaise"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   930
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   931
    "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   932
     Object messageNotUnderstoodSignal handle:[:ex |
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   933
	'oops' printNL.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   934
	ex return
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   935
     ] do:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   936
	123 size open   
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   937
     ]
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   938
     "
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   939
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   940
     "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   941
      |num|
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   943
      num := 0.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   944
      Number divisionByZeroSignal handle:[:ex |
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   945
	  'oops' printNL.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   946
	  ex return
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   947
      ] do:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   948
	  123 / num   
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   949
      ]
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   950
     "
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
    "Created: / 23.7.1999 / 14:06:13 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   953
    "Modified: / 25.7.1999 / 19:44:05 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   954
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   955
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   956
handle:handleBlock from:anObject do:aBlock
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   957
    "evaluate the argument, aBlock.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   958
     If the receiver-signal is raised during evaluation,
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   959
     and the exception originated from anObject,
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   960
     evaluate the handleBlock passing it an Exception argument.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   961
     The handler may decide how to react to the signal by sending
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
     a corresponding message to the exception (see there).
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
     If the signal is not raised, return the value of evaluating
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
     aBlock."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   966
    <context: #return>
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
   967
    <exception: #handle>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
   968
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   969
    "/ thisContext markForHandle. -- same as above pragma
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   970
    ^ aBlock value  "the real logic is in Exception>>doRaise"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   972
    "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   973
     the first open will be caught; the second not:
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   975
     |o1 o2|
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   976
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   977
     o1 := 123.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   978
     o2 := nil.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   979
     Object messageNotUnderstoodSignal 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   980
	 handle:
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   981
		[:ex |
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   982
		    'oops' printNL.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   983
		    ex proceed
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   984
		] 
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   985
	 from:o1
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   986
	 do:
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   987
		[
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   988
		    o1 open.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   989
		    o2 open
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
   990
		]
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   991
    "
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
    "Created: / 23.7.1999 / 14:06:26 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   994
    "Modified: / 25.7.1999 / 19:44:13 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   997
ignoreIn:aBlock
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   998
    "evaluate the argument, aBlock.
6426
8b6a357addb6 comment change
Claus Gittinger <cg@exept.de>
parents: 6396
diff changeset
   999
     Ignore the receiver-signal during evaluation - i.e. simply continue. 
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  1000
     This makes only sense for some signals, such as UserInterrupt
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  1001
     or AbortSignal, because continuing after an exception without any cleanup
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  1002
     often leads to followup-errors."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  1004
    ^ self handle:[:ex | ex proceedWith:nil] do:aBlock.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  1006
    "
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  1007
     Object messageNotUnderstoodSignal ignoreIn:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1008
	123 size open   
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  1009
     ]
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  1010
    "
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1011
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1012
    "Created: / 23.7.1999 / 14:06:40 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1013
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1014
7296
2b8a6ee9a1cf category
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
  1015
!GenericException class methodsFor:'compatibility-signal creation'!
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1016
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
newSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
    "create a new signal, using the receiver as a prototype and
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
     setting the parent of the new signal to the receiver."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
    ^ self newSignalMayProceed:self mayProceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1023
    "Created: / 23.7.1999 / 20:13:23 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
7559
cee46c568fd3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7558
diff changeset
  1026
newSignalMayProceed:mayProceedBoolean
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
    "create a new signal, using the receiver as a prototype and
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
     setting the parent of the new signal to the receiver."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
7556
5d78f93528b4 newSignal should generate a Query if the Ex is one
Claus Gittinger <cg@exept.de>
parents: 7296
diff changeset
  1030
    |sig|
5d78f93528b4 newSignal should generate a Query if the Ex is one
Claus Gittinger <cg@exept.de>
parents: 7296
diff changeset
  1031
5d78f93528b4 newSignal should generate a Query if the Ex is one
Claus Gittinger <cg@exept.de>
parents: 7296
diff changeset
  1032
    self isQuerySignal ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1033
	sig := QuerySignal basicNew.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1034
	mayProceedBoolean ifFalse:[
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1035
	    'Exception [warning]: nonProceedable Queries do not make sense' infoPrintCR.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1036
	].
7556
5d78f93528b4 newSignal should generate a Query if the Ex is one
Claus Gittinger <cg@exept.de>
parents: 7296
diff changeset
  1037
    ] ifFalse:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1038
	sig := Signal basicNew.
7556
5d78f93528b4 newSignal should generate a Query if the Ex is one
Claus Gittinger <cg@exept.de>
parents: 7296
diff changeset
  1039
    ].
5d78f93528b4 newSignal should generate a Query if the Ex is one
Claus Gittinger <cg@exept.de>
parents: 7296
diff changeset
  1040
    ^ sig 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1041
	mayProceed:mayProceedBoolean;
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1042
	notifierString:NotifierString;
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1043
	parent:self
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
    "Created: / 23.7.1999 / 20:12:43 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1046
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1047
5837
f5510a4c6f75 Add signals to SignalSets with #,
Stefan Vogel <sv@exept.de>
parents: 5697
diff changeset
  1048
!GenericException class methodsFor:'converting'!
f5510a4c6f75 Add signals to SignalSets with #,
Stefan Vogel <sv@exept.de>
parents: 5697
diff changeset
  1049
8238
157e002fb7cf fix comment
Stefan Vogel <sv@exept.de>
parents: 8070
diff changeset
  1050
, anExceptionHandler
157e002fb7cf fix comment
Stefan Vogel <sv@exept.de>
parents: 8070
diff changeset
  1051
    "return a SignalSet with myself and anExceptionHandler"
157e002fb7cf fix comment
Stefan Vogel <sv@exept.de>
parents: 8070
diff changeset
  1052
157e002fb7cf fix comment
Stefan Vogel <sv@exept.de>
parents: 8070
diff changeset
  1053
    ^ SignalSet with:self with:anExceptionHandler
5837
f5510a4c6f75 Add signals to SignalSets with #,
Stefan Vogel <sv@exept.de>
parents: 5697
diff changeset
  1054
! !
f5510a4c6f75 Add signals to SignalSets with #,
Stefan Vogel <sv@exept.de>
parents: 5697
diff changeset
  1055
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1056
!GenericException class methodsFor:'printing'!
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1057
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1058
description
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1059
    "return the notifier string.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1060
     If the notifier string starts with space, prepend
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1061
     the parents notifier string.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1062
     Subclasses may redefine this method."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
5927
6239b98251a6 avoid recursive error in #description if parent is nil
Claus Gittinger <cg@exept.de>
parents: 5867
diff changeset
  1064
    |parent|
6239b98251a6 avoid recursive error in #description if parent is nil
Claus Gittinger <cg@exept.de>
parents: 5867
diff changeset
  1065
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1066
    NotifierString isNil ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1067
	^ self name asString
4606
21bf9124f4ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
  1068
    ].
21bf9124f4ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
  1069
    (NotifierString startsWith:Character space) ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1070
	(parent := self parent) notNil ifTrue:[
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1071
	    ^ parent description, NotifierString
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1072
	].
4606
21bf9124f4ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
  1073
    ].
21bf9124f4ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
  1074
    ^ NotifierString
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1075
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1076
    "
4606
21bf9124f4ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
  1077
     Object errorSignal description
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1078
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1079
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1080
    "Created: / 23.7.1999 / 14:22:25 / stefan"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
6200
65f0631e5221 added #isControlInterrupt
Claus Gittinger <cg@exept.de>
parents: 6198
diff changeset
  1083
!GenericException class methodsFor:'queries'!
65f0631e5221 added #isControlInterrupt
Claus Gittinger <cg@exept.de>
parents: 6198
diff changeset
  1084
65f0631e5221 added #isControlInterrupt
Claus Gittinger <cg@exept.de>
parents: 6198
diff changeset
  1085
isControlInterrupt
65f0631e5221 added #isControlInterrupt
Claus Gittinger <cg@exept.de>
parents: 6198
diff changeset
  1086
    ^ false
65f0631e5221 added #isControlInterrupt
Claus Gittinger <cg@exept.de>
parents: 6198
diff changeset
  1087
65f0631e5221 added #isControlInterrupt
Claus Gittinger <cg@exept.de>
parents: 6198
diff changeset
  1088
    "Created: / 16.11.2001 / 16:11:54 / cg"
65f0631e5221 added #isControlInterrupt
Claus Gittinger <cg@exept.de>
parents: 6198
diff changeset
  1089
! !
65f0631e5221 added #isControlInterrupt
Claus Gittinger <cg@exept.de>
parents: 6198
diff changeset
  1090
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1091
!GenericException class methodsFor:'useful handlers'!
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1092
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1093
abortingEmergencyHandler
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1094
    "return a block (usable as an emergency handler), 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1095
     which aborts after showing a warnBox.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1096
     This is useful for endUser applications.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1097
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1098
     WARNING: this method belongs to NoHandlerError, and may eventually be
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1099
     moved there - it is (for now) left here for backward compatibility."
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1100
5295
f144309dab04 #errorString --> #description
Stefan Vogel <sv@exept.de>
parents: 5259
diff changeset
  1101
    ^ [:ex | self warn:'Error: ' , ex description.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1102
             AbortOperationRequest raise 
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1103
      ]
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1104
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1105
    "test with (try a few halts or CTRL-C's):
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1106
     NoHandlerError emergencyHandler:(NoHandlerError abortingEmergencyHandler)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1107
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1108
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1109
    "back with:
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1110
     NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandler)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1111
     NoHandlerError emergencyHandler:nil
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1112
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1113
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1114
    "Created: 15.1.1997 / 20:13:06 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1115
    "Modified: 15.1.1997 / 20:15:02 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1116
!
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1117
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1118
dumpingEmergencyHandler
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1119
    "return a block (usable as an emergency handler), 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1120
     which dumps the stackBacktrace to a trace file and
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1121
     aborts after showing a warnBox.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1122
     This is useful, for endUser application, which are still being
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1123
     debugged (i.e. the programmers may have a look at the traceFile
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1124
     from time to time).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1125
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1126
     Notice:
8254
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1127
         The code below is just an example; you may want to change the
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1128
         name of the error-file in your application
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1129
         (but please: copy the code; do not modify here)
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1130
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1131
     WARNING: this method belongs to NoHandlerError, and may eventually be
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1132
     moved there - it is (for now) left here for backward compatibility."
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1133
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1134
    ^ [:ex | 
8254
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1135
             |str printedException|
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1136
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1137
             ex signal == NoHandlerError ifTrue:[
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1138
                printedException := ex parameter.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1139
             ] ifFalse:[
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1140
                printedException := ex
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1141
             ].
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1142
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1143
             "/ user interruption is handled specially:
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1144
             "/ allow user to choose between proceeding or aborting
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1145
             "/ but never dump that information to the file.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1146
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1147
             printedException signal == Object userInterruptSignal ifTrue:[
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1148
                  (self confirm:'abort current action ?') ifTrue:[
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1149
                      AbortOperationRequest raise
8254
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1150
                  ].
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1151
                  ex proceedWith:nil
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1152
             ].
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1153
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1154
             "/
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1155
             "/ dump it to 'errorTrace.stx'
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1156
             "/
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1157
             str := 'errorTrace.stx' asFilename appendingWriteStream.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1158
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1159
             str nextPutLine:('******************************* '
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1160
                              , Timestamp now printString
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1161
                              , ' *******************************').
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1162
             str cr.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1163
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1164
             str nextPutLine:('** Error: ' , printedException description).
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1165
             str nextPutLine:('** Signal: ' , printedException signal printString).
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1166
             str nextPutLine:('** Parameter: ' , printedException parameter printString).
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1167
             str nextPutLine:('** Process: ' , Processor activeProcess printString).
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1168
             str nextPutLine:('** Backtrace:').
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1169
             str cr.
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1170
        
8254
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1171
             printedException suspendedContext fullPrintAllOn:str.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1172
             str cr.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1173
             str cr.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1174
             str close.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1175
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1176
             "/ send a line to stdErr
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1177
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1178
             ('[warning]: ignored error: ' , printedException description) errorPrintCR.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1179
             ('[warning]:    error information appended to ''errorTrace.stx''') errorPrintCR.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1180
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1181
             AbortOperationRequest raise 
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1182
      ]
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1183
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1184
    "test with (try a few halts or CTRL-C's):
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1185
     NoHandlerError emergencyHandler:(NoHandlerError dumpingEmergencyHandler)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1186
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1187
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1188
    "back with:
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1189
     NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandler)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1190
     NoHandlerError emergencyHandler:nil
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1191
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1192
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1193
    "Created: / 15.1.1997 / 20:14:52 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1194
    "Modified: / 24.1.1997 / 20:36:21 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1195
    "Modified: / 4.8.1999 / 08:11:20 / stefan"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1196
!
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1197
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1198
mailingEmergencyHandler
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1199
    "return a block (usable as an emergency handler), 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1200
     which shows a warnBox and optionally mails a stackBacktrace to a maintainer.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1201
     This is useful, for endUser application, which are still being
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1202
     debugged (i.e. the programmers may have a look at the errors).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1203
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1204
     Notice: the stuff here is a demonstration only; it should be modified
8254
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1205
             for your particular environment ...
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1206
             ... but please: copy the code and modify there;
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1207
             leave the stuff below as it is.
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1208
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1209
     WARNING: this method belongs to NoHandlerError, and may eventually be
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1210
     moved there - it is (for now) left here for backward compatibility."
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1211
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1212
    ^ [:ex | 
8254
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1213
            |str printedException doMail emergencyMailReceiver pipe|
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1214
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1215
            ex signal == NoHandlerError ifTrue:[
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1216
               printedException := ex parameter.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1217
            ] ifFalse:[
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1218
               printedException := ex
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1219
            ].
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1220
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1221
             "/ user interruption is handled specially:
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1222
             "/ allow user to choose between proceeding or aborting
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1223
             "/ but never dump that information to the file.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1224
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1225
             printedException signal == UserInterrupt ifTrue:[
8254
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1226
                  (self confirm:'abort current action ?') ifTrue:[
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1227
                      AbortOperationRequest raise
8254
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1228
                  ].
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1229
                  ex proceedWith:nil
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1230
             ].
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1231
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1232
            "/ somehow get the name of the guy to receive the mail
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1233
            "/ you have to implement that yourself.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1234
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1235
            "/ emergencyMailReceiver := OneOfYourClass getEmergencyMailReceiver.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1236
            emergencyMailReceiver := OperatingSystem getLoginName.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1237
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1238
            emergencyMailReceiver isNil ifTrue:[
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1239
                self warn:(printedException description 
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1240
                           , '\\No mailing to service people possible.') withCRs.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1241
                doMail := false.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1242
            ] ifFalse:[
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1243
                doMail := self confirm:(printedException description 
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1244
                                        , '\\Mail error information to the service people (' 
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1245
                                        , emergencyMailReceiver , ') ?') withCRs
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1246
            ].
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1247
            doMail ifTrue:[
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1248
                str := '' writeStream.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1249
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1250
                str nextPutLine:('Error notification from '
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1251
                                , OperatingSystem getLoginName
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1252
                                , '@'
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1253
                                , OperatingSystem getHostName).
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1254
                str cr.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1255
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1256
                str nextPutLine:('Time: ' , Timestamp now printString).
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1257
                str nextPutLine:('Error: ', printedException description).
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1258
                str nextPutLine:('Signal: ', printedException signal printString).
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1259
                str nextPutLine:('Parameter: ', printedException parameter printString).
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1260
                str nextPutLine:('Process: ', Processor activeProcess printString).
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1261
                str nextPutLine:'Backtrace:'.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1262
                str cr.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1263
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1264
                printedException suspendedContext fullPrintAllOn:str.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1265
                str cr;cr.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1266
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1267
                str close.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1268
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1269
                pipe := PipeStream 
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1270
                            writingTo:'mail ', emergencyMailReceiver.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1271
                pipe notNil ifTrue:[
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1272
                    pipe nextPutLine:'Subject: automatic error report'.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1273
                    pipe nextPutAll:str contents.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1274
                    pipe cr.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1275
                    pipe close.
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1276
                ]
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1277
             ].
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8238
diff changeset
  1278
8390
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1279
             AbortOperationRequest raise.
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1280
             "not reached"
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1281
      ]
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1282
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1283
    "test with (try a few halts or CTRL-C's):
6581
cc98fd762ea5 Fix examples
Stefan Vogel <sv@exept.de>
parents: 6510
diff changeset
  1284
     NoHandlerError emergencyHandler:(NoHandlerError mailingEmergencyHandler)
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1285
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1286
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1287
    "back with:
6581
cc98fd762ea5 Fix examples
Stefan Vogel <sv@exept.de>
parents: 6510
diff changeset
  1288
     NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandler)
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1289
     NoHandlerError emergencyHandler:nil
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1290
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1291
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1292
    "Created: / 15.1.1997 / 20:14:52 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1293
    "Modified: / 15.1.1997 / 21:10:28 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1294
    "Modified: / 4.8.1999 / 08:11:26 / stefan"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1295
!
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1296
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1297
notifyingEmergencyHandler
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1298
    "return a block (usable as an emergency handler for exceptions), 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1299
     which does errorNotification before going into the debugger.
6198
9c2324d1befa better emergencyHandlers (do not ask for breaks/halts)
Claus Gittinger <cg@exept.de>
parents: 6174
diff changeset
  1300
     Halts and breakpoints go directly into the debugger (without asking)
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1301
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1302
     WARNING: this method belongs to NoHandlerError, and may eventually be
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1303
     moved there - it is (for now) left here for backward compatibility."
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1304
6198
9c2324d1befa better emergencyHandlers (do not ask for breaks/halts)
Claus Gittinger <cg@exept.de>
parents: 6174
diff changeset
  1305
    ^ [:ex | 
8390
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1306
        (ex signal == NoHandlerError 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1307
        and:[ex parameter signal inheritsFrom:ControlInterrupt]) ifTrue:[
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1308
            "/ go directly into the debugger ...
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1309
            ^ Debugger 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1310
                enter:ex suspendedContext 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1311
                withMessage:ex description
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1312
                mayProceed:true
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1313
        ] ifFalse:[
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1314
            "/ ask, and maybe go into the debugger ...
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1315
            ^ nil 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1316
                errorNotify:ex description 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1317
                from:ex suspendedContext 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1318
                allowDebug:true 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1319
        ]
6198
9c2324d1befa better emergencyHandlers (do not ask for breaks/halts)
Claus Gittinger <cg@exept.de>
parents: 6174
diff changeset
  1320
      ]
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1321
6581
cc98fd762ea5 Fix examples
Stefan Vogel <sv@exept.de>
parents: 6510
diff changeset
  1322
    "test with (NOTE: halt, breakpoints or CTRL-C's still go straight into the debugger):
cc98fd762ea5 Fix examples
Stefan Vogel <sv@exept.de>
parents: 6510
diff changeset
  1323
     NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandler).
cc98fd762ea5 Fix examples
Stefan Vogel <sv@exept.de>
parents: 6510
diff changeset
  1324
     Object bla.
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1325
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1326
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1327
    "back with:
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1328
     NoHandlerError emergencyHandler:nil
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1329
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1330
6198
9c2324d1befa better emergencyHandlers (do not ask for breaks/halts)
Claus Gittinger <cg@exept.de>
parents: 6174
diff changeset
  1331
    "Modified: / 16.11.2001 / 16:07:05 / cg"
5058
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1332
!
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1333
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1334
notifyingEmergencyHandlerForUserProcesses
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1335
    "return a block (usable as an emergency handler for exceptions), 
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1336
     which does errorNotification before going into the debugger,
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1337
     but only for exceptions occurring in user processes;
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1338
     systemProcesses are not debugged.
6198
9c2324d1befa better emergencyHandlers (do not ask for breaks/halts)
Claus Gittinger <cg@exept.de>
parents: 6174
diff changeset
  1339
     Halts and breakpoints go directly into the debugger (without asking)
5058
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1340
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1341
     WARNING: this method belongs to NoHandlerError, and may eventually be
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1342
     moved there - it is (for now) left here for backward compatibility."
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1343
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1344
    ^ [:ex | 
5059
a217f2821e7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5058
diff changeset
  1345
8390
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1346
        |theException|
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1347
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1348
        Processor activeProcessIsSystemProcess ifTrue:[
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1349
            'EmergencyHandler [info]: exception cought: ' errorPrint.
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1350
            ex signal == NoHandlerError ifTrue:[
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1351
                theException := ex parameter.
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1352
            ] ifFalse:[
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1353
                theException := ex
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1354
            ].
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1355
            theException description errorPrintCR.
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1356
            AbortOperationRequest raise.
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1357
        ] ifFalse:[
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1358
            (ex signal == NoHandlerError 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1359
            and:[ex parameter signal inheritsFrom:ControlInterrupt]) ifTrue:[
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1360
                "/ go directly into the debugger ...
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1361
                ^ Debugger 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1362
                    enter:ex suspendedContext 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1363
                    withMessage:ex description
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1364
                    mayProceed:true
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1365
            ] ifFalse:[
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1366
                "/ ask, and maybe go into the debugger ...
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1367
                ^ nil 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1368
                    errorNotify:ex description 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1369
                    from:ex suspendedContext
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1370
                    allowDebug:true
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1371
            ]
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1372
        ]
5058
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1373
      ]
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1374
6581
cc98fd762ea5 Fix examples
Stefan Vogel <sv@exept.de>
parents: 6510
diff changeset
  1375
    "test with:
cc98fd762ea5 Fix examples
Stefan Vogel <sv@exept.de>
parents: 6510
diff changeset
  1376
     NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandlerForUserProcesses)
cc98fd762ea5 Fix examples
Stefan Vogel <sv@exept.de>
parents: 6510
diff changeset
  1377
     Object bla.
5058
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1378
    "
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1379
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1380
    "back with:
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1381
     NoHandlerError emergencyHandler:nil
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1382
    "
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1383
6198
9c2324d1befa better emergencyHandlers (do not ask for breaks/halts)
Claus Gittinger <cg@exept.de>
parents: 6174
diff changeset
  1384
    "Modified: / 16.11.2001 / 16:06:54 / cg"
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1385
! !
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1386
7261
f35fc9cee675 method category rename
Claus Gittinger <cg@exept.de>
parents: 6945
diff changeset
  1387
!GenericException methodsFor:'Compatibility-ANSI'!
5680
7c27d1de0c56 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
  1388
5933
af2939dac9bf added #pass for compatibility
Claus Gittinger <cg@exept.de>
parents: 5927
diff changeset
  1389
pass
af2939dac9bf added #pass for compatibility
Claus Gittinger <cg@exept.de>
parents: 5927
diff changeset
  1390
    ^ self reject
af2939dac9bf added #pass for compatibility
Claus Gittinger <cg@exept.de>
parents: 5927
diff changeset
  1391
!
af2939dac9bf added #pass for compatibility
Claus Gittinger <cg@exept.de>
parents: 5927
diff changeset
  1392
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1393
retry
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1394
    "same as #restart - ANSI & VW compatibility"
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1395
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1396
    self restart
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1397
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1398
    "Created: / 7.9.2001 / 13:31:02 / cg"
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1399
!
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1400
7674
73acec69e93c compatibility: +retryUsing:
Claus Gittinger <cg@exept.de>
parents: 7631
diff changeset
  1401
retryUsing: alternativeBlock
73acec69e93c compatibility: +retryUsing:
Claus Gittinger <cg@exept.de>
parents: 7631
diff changeset
  1402
    "Abort an exception handler and evaluate a new block in place of the handler's protected block."
73acec69e93c compatibility: +retryUsing:
Claus Gittinger <cg@exept.de>
parents: 7631
diff changeset
  1403
73acec69e93c compatibility: +retryUsing:
Claus Gittinger <cg@exept.de>
parents: 7631
diff changeset
  1404
    "/ self mustBeHandled ifFalse: [ ^self ].
73acec69e93c compatibility: +retryUsing:
Claus Gittinger <cg@exept.de>
parents: 7631
diff changeset
  1405
73acec69e93c compatibility: +retryUsing:
Claus Gittinger <cg@exept.de>
parents: 7631
diff changeset
  1406
    ^ self restartDo:alternativeBlock
73acec69e93c compatibility: +retryUsing:
Claus Gittinger <cg@exept.de>
parents: 7631
diff changeset
  1407
!
73acec69e93c compatibility: +retryUsing:
Claus Gittinger <cg@exept.de>
parents: 7631
diff changeset
  1408
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1409
signalWith:messageText
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1410
    ^ self raiseErrorString:messageText
5697
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  1411
! !
5680
7c27d1de0c56 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
  1412
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1413
!GenericException methodsFor:'accessing'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1414
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1415
creator
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1416
    "return the creator of the exception"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1417
6453
b3dfd873f395 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6430
diff changeset
  1418
    signal == nil ifTrue:[ 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1419
	^ self class 
6453
b3dfd873f395 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6430
diff changeset
  1420
    ].
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1421
    ^ signal
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1422
!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1423
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1424
errorString 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1425
    "return the errorString passsed with the signal raise
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1426
     (or nil, if there was none).
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1427
     #errorString is deprecated, use description instead"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
6859
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
  1429
    <resource:#obsolete>
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1430
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1431
    ^ self description
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1432
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1433
    "Modified: / 12.3.1998 / 15:13:28 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1434
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1435
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1436
errorString:aString 
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1437
    "set the messageText.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1438
     If it starts with a space, the signals messageText is prepended,
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1439
     if it ends with a space, it is appended.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1440
     #errorString: is deprecated, use messageText: instead"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
6859
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
  1442
    <resource:#obsolete>
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
  1443
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1444
    messageText := aString
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1445
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1446
    "Created: / 5.3.1998 / 16:45:29 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1447
    "Modified: / 12.3.1998 / 15:30:45 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1448
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1449
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1450
handlerContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
    "return the context of the handler"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1453
    ^ handlerContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1454
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1455
4483
55530226d243 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4481
diff changeset
  1456
handlingException
55530226d243 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4481
diff changeset
  1457
    "return the handling exception (or signalSet or Exception).
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1458
     This is only valid during handler evaluation, and answers
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1459
     the object which accepted the actual signal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1460
     (i.e. the parent or signalSet or handlerCollection)"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
4483
55530226d243 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4481
diff changeset
  1462
    ^ handlingException
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1465
isResumable
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1466
    "return true, if the exception is resumable"
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1467
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1468
    ^ proceedable
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1469
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1470
    "Modified: / 2.3.1998 / 12:20:43 / stefan"
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1471
!
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1472
7597
db72d9d640bc +isResumable: (VW compat.)
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  1473
isResumable:aBoolean
db72d9d640bc +isResumable: (VW compat.)
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  1474
    proceedable := aBoolean
db72d9d640bc +isResumable: (VW compat.)
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  1475
!
db72d9d640bc +isResumable: (VW compat.)
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  1476
5950
5757b9ba4ff2 added #messageText
Claus Gittinger <cg@exept.de>
parents: 5939
diff changeset
  1477
messageText
7808
824d0e2a3f5c fix spelling error
Stefan Vogel <sv@exept.de>
parents: 7753
diff changeset
  1478
    "return the explicit given messageText - nil, if signaler did not provide one."
5950
5757b9ba4ff2 added #messageText
Claus Gittinger <cg@exept.de>
parents: 5939
diff changeset
  1479
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1480
    ^ messageText
5950
5757b9ba4ff2 added #messageText
Claus Gittinger <cg@exept.de>
parents: 5939
diff changeset
  1481
!
5757b9ba4ff2 added #messageText
Claus Gittinger <cg@exept.de>
parents: 5939
diff changeset
  1482
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1483
messageText:aString 
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1484
    "set the messageText.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1485
     If it starts with a space, the signals messageText is prepended,
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1486
     if it ends with a space, it is appended."
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1487
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1488
    messageText := aString
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1489
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1490
    "Created: / 5.3.1998 / 16:45:29 / stefan"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1491
    "Modified: / 12.3.1998 / 15:30:45 / stefan"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1492
!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1493
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1494
originator 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
    "return the originator passsed with the signal raise
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
     (or nil, if there was none)"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1497
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1498
    ^ originator
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1501
originator:anObject 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1502
    "set the originator"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1503
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1504
    originator := anObject
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1505
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1506
    "Created: / 5.3.1998 / 16:34:56 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1507
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1508
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1509
parameter
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1510
    "return the parameter passsed with the signal raise
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1511
     (or nil, if there was none)"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1512
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1513
    ^ parameter
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1514
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1515
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1516
parameter:anObject
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1517
    "set the parameter of the exception"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1518
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1519
    parameter := anObject
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1520
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1521
    "Created: / 5.3.1998 / 16:34:22 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1522
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1523
6036
6b37c7a6f6b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5985
diff changeset
  1524
proceedable:aBoolean
6b37c7a6f6b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5985
diff changeset
  1525
    proceedable := aBoolean
6b37c7a6f6b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5985
diff changeset
  1526
!
6b37c7a6f6b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5985
diff changeset
  1527
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1528
rejected
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1529
    "return true, if any other of the exceptions handlers has rejected 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1530
     Uncertain, if this is really interesting to anybody.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1531
     This is only valid during handler execution.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1532
     (i.e. an outer handler can find out, if any other handler has already
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1533
     rejected).
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  1534
     Currently only used to change the 'unhandled-exception' messageText 
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1535
     into 'rejected-exception' for information).
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1536
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1537
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1538
    ^ rejected == true
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1539
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1540
5697
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  1541
searchFrom:raisingContext 
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  1542
    suspendedContext := raisingContext
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  1543
!
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  1544
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1545
signal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1546
    "return the signal, that caused the exception"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1547
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1548
    ^ signal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1549
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1550
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1551
signal:aSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1552
    "set the signal, that caused the exception"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1553
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1554
    signal := aSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1555
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1556
    "Created: / 5.3.1998 / 16:02:46 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1557
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1558
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1559
suspendedContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1560
    "return the context in which the raise occured"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1561
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1562
    ^ suspendedContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1563
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1564
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1565
suspendedContext:something
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1566
    "set the value of the instance variable 'suspendedContext' (automatically generated)"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1567
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1568
    suspendedContext := something.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1569
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1570
    "Created: / 2.3.1998 / 12:43:20 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1571
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1572
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1573
willProceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1574
    "return true, if the exception is proceedable"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1575
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1576
    ^ self isResumable
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1577
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1578
    "Modified: / 2.3.1998 / 12:20:43 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1579
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1580
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1581
!GenericException methodsFor:'copying'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1582
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1583
postCopy
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1584
    "set the internal state to nil"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1585
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1586
    suspendedContext := handlerContext := rejected := nil
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1587
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1588
    "Created: / 2.3.1998 / 12:30:06 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1589
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1590
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1591
!GenericException methodsFor:'default actions'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1592
4527
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4521
diff changeset
  1593
defaultAction
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1594
    "perform a action for the exception if it hasn't been catched
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1595
     We arrive here, if either no handler was found, or none of the
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1596
     handlers did a return (i.e. every handler rejected).
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1597
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1598
     The default is to evaluate the signal's handlerBlock or 
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1599
     to raise the noHandlerSignal.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1600
     Subclasses may redefine this."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1601
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1602
    |handlerBlock|
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1603
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1604
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1605
     try per signal handler
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1606
    "
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1607
    (handlerBlock := signal handlerBlock) notNil ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1608
	"... and call it"
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1609
	^ handlerBlock value:self.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1610
    ].
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1611
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1612
    "/ if its a querySignal, ignore it
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1613
    signal isQuerySignal ifTrue:[^ nil].
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1614
    ^ self noHandler.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1615
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1616
    "Created: / 23.7.1999 / 14:38:03 / stefan"
4517
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
  1617
    "Modified: / 4.8.1999 / 08:11:05 / stefan"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1618
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1619
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1620
mayProceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1621
    "return true, if the exception handler is allowed to proceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1622
     the execution where the exception occured.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1623
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1624
     Subclasses may redefine this."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1625
6920
ff7892b5b41a no longer raise ProceedError
Claus Gittinger <cg@exept.de>
parents: 6859
diff changeset
  1626
    proceedable notNil ifTrue:[^ proceedable].
ff7892b5b41a no longer raise ProceedError
Claus Gittinger <cg@exept.de>
parents: 6859
diff changeset
  1627
    signal notNil ifTrue:[^ signal mayProceed].
ff7892b5b41a no longer raise ProceedError
Claus Gittinger <cg@exept.de>
parents: 6859
diff changeset
  1628
    ^ self class mayProceed
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1629
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1630
    "Created: / 23.7.1999 / 14:48:26 / stefan"
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1631
!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1632
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1633
noHandler
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1634
    "raise the NoHandlerError.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1635
     NohandlerError redefines this method to avoid recursive invocations"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1636
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1637
    <context: #return>
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1638
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1639
    |msg|
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1640
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1641
    rejected == true ifTrue:[
8390
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1642
        msg := 'unhandled (rejected)'
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1643
    ] ifFalse:[
8390
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1644
        msg := 'unhandled'
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1645
    ].
5295
f144309dab04 #errorString --> #description
Stefan Vogel <sv@exept.de>
parents: 5259
diff changeset
  1646
    msg := msg , ' exception: (' , self description , ')'.
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1647
    self mayProceed ifTrue:[
8390
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1648
        ^ NoHandlerError 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1649
              raiseRequestWith:self 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1650
              errorString:msg
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1651
              in:suspendedContext.
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1652
    ].
8390
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1653
    ^ NoHandlerError 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1654
          raiseWith:self 
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1655
          errorString:msg
d78cd984f201 return values for #proceedWith:
Stefan Vogel <sv@exept.de>
parents: 8313
diff changeset
  1656
          in:suspendedContext.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1657
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1658
5984
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1659
!GenericException methodsFor:'default values'!
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1660
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1661
defaultResumeValue
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1662
    ^ nil
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1663
!
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1664
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1665
defaultReturnValue
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1666
    ^ nil
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1667
! !
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1668
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1669
!GenericException methodsFor:'handler actions'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1670
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1671
exit
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1672
    "either resume or return - depending on the receivers resumability.
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1673
     VW compatibility."
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1674
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1675
    self isResumable ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1676
	self resume:(self defaultResumeValue)
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1677
    ] ifFalse:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1678
	self return:(self defaultReturnValue)
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1679
    ]
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1680
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1681
    "Modified: / 7.9.2001 / 13:28:54 / cg"
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1682
!
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1683
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1684
exit:value
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1685
    "either resume or return - depending on the receivers resumability.
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1686
     VW compatibility."
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1687
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1688
    self isResumable ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1689
	self resume:value
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1690
    ] ifFalse:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1691
	self return:value
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1692
    ]
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1693
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1694
    "Created: / 7.9.2001 / 13:29:55 / cg"
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1695
    "Modified: / 7.9.2001 / 13:30:00 / cg"
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1696
!
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1697
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1698
proceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1699
    "Continue after the raise - the raise returns nil"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1700
5984
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1701
    self proceedWith:(self defaultResumeValue).
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1702
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1703
    "cg: a strange example: 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1704
	there are two cought errors here - can you spot them ?
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1705
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1706
     Object errorSignal handle:[:ex|
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1707
	 'proceeding' printCR.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1708
	 ex proceed
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1709
     ] do:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1710
	 Object errorSignal raiseRequest
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1711
     ].
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1712
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1713
4517
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
  1714
    "Modified: / 4.8.1999 / 08:42:12 / stefan"
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1715
    "Modified: / 7.9.2001 / 13:29:08 / cg"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1716
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1717
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1718
proceedWith:value
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1719
    "Continue after the raise - the raise returns value"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1720
4507
c15d849b1ddc Remove unused vars.
Stefan Vogel <sv@exept.de>
parents: 4504
diff changeset
  1721
    |con|
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1722
6920
ff7892b5b41a no longer raise ProceedError
Claus Gittinger <cg@exept.de>
parents: 6859
diff changeset
  1723
"/    proceedable ifFalse:[
ff7892b5b41a no longer raise ProceedError
Claus Gittinger <cg@exept.de>
parents: 6859
diff changeset
  1724
"/        "proceed from ProceedError to recover from this error"
ff7892b5b41a no longer raise ProceedError
Claus Gittinger <cg@exept.de>
parents: 6859
diff changeset
  1725
"/        ProceedError raiseRequestWith:self.
ff7892b5b41a no longer raise ProceedError
Claus Gittinger <cg@exept.de>
parents: 6859
diff changeset
  1726
"/        proceedable := true.
ff7892b5b41a no longer raise ProceedError
Claus Gittinger <cg@exept.de>
parents: 6859
diff changeset
  1727
"/    ].
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1728
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1729
    thisContext evaluateUnwindActionsUpTo:suspendedContext.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1730
    suspendedContext resumeIgnoringErrors:value.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1731
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1732
    "/ arrive here, if suspended context is not resumable -
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1733
    "/ sigh; resume our raise context ...
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1734
    "/ ... consider this a fallBack kludge, for the case that
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1735
    "/ a raising context is not returnable.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1736
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1737
    "/ find my raise context
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1738
    con := Context findFirstSpecialHandle:false raise:true.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1739
    [con notNil 
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1740
     and:[con receiver ~~ self]] whileTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1741
	con := con findSpecialHandle:false raise:true.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1742
    ].
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1743
    "/ now, have the doCallXXX context at-hand
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1744
    con := con sender.
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1745
    "/ now, have the doRaise context at-hand
4632
522e8accc413 oops - proceed was wrong
Claus Gittinger <cg@exept.de>
parents: 4606
diff changeset
  1746
    con := con sender.
522e8accc413 oops - proceed was wrong
Claus Gittinger <cg@exept.de>
parents: 4606
diff changeset
  1747
    "/ now, have the raise context at-hand
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1748
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1749
    handlerContext := suspendedContext := nil.
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1750
    con resume:value.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1751
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1752
    "Modified: / 27.3.1997 / 16:45:57 / cg"
4517
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
  1753
    "Modified: / 4.8.1999 / 08:42:17 / stefan"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1754
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1755
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1756
reject
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1757
    "handler decided not to handle this signal -
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1758
     system will look for another handler"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1759
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1760
    |con|
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1761
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1762
    "/ find my raise context
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1763
    con := Context findFirstSpecialHandle:false raise:true.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1764
    [con notNil 
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1765
     and:[con receiver ~~ self]] whileTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1766
	con := con findSpecialHandle:false raise:true.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1767
    ].
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1768
    "/ now, have the doCallXXX context at-hand
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1769
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1770
    rejected := true.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1771
    con unwind:nil.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1772
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1773
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1774
     Object errorSignal handle:[:ex |
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1775
	'1' printCR.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1776
	ex reject
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1777
     ] do:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1778
	Object errorSignal handle:[:ex |
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1779
	    '2' printCR.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1780
	    ex reject
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1781
	] do:[
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1782
	    #() at:1
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1783
	]
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1784
     ]
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1785
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1786
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1787
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1788
resignalAs:anotherException
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1789
    "resignal anotherException, as if it was raised in the first place"
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1790
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1791
    |con|
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1792
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1793
    con := suspendedContext.
6364
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1794
    con canReturn ifFalse:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1795
	"the context that triggered the exception cannot return.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1796
	 This is a fallback: return the the context of the raise*.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1797
	 We know, that this context is returnable"
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1798
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1799
	con := Context findFirstSpecialHandle:false raise:true.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1800
	[con notNil and:[con receiver ~~ self]] whileTrue:[
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1801
	    con := con findSpecialHandle:false raise:true.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1802
	].
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1803
	[con notNil and:[con sender ~~ suspendedContext]] whileTrue:[
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1804
	    con := con sender.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1805
	].
6364
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1806
    ].
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1807
    handlerContext := suspendedContext := nil.
6364
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1808
    con unwindThenDo:[anotherException raiseSignal].
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1809
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1810
    "
6364
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1811
     |rslt|
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1812
7753
a4de4f3a203f comments
Stefan Vogel <sv@exept.de>
parents: 7674
diff changeset
  1813
     ZeroDivide handle:[:ex |
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1814
	ex resignalAs:Number domainErrorSignal
6364
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1815
     ] do:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1816
	rslt := 5 // 0
6364
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1817
     ].
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1818
     rslt
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1819
    "
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1820
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1821
    "
b7d1a52ec256 Workaround for non-returnable contexts in #resignalAs:
Stefan Vogel <sv@exept.de>
parents: 6264
diff changeset
  1822
     |rslt|
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1823
7753
a4de4f3a203f comments
Stefan Vogel <sv@exept.de>
parents: 7674
diff changeset
  1824
     MessageNotUnderstood handle:[:ex |
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1825
	ex resignalAs:Number domainErrorSignal
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1826
     ] do:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1827
	rslt := 1 perform:#foo
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1828
     ].
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1829
     rslt
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1830
    "
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1831
!
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1832
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1833
restart
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1834
    "restart the handle:do: - usually after some repair work is done
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1835
     in the handler"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1836
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1837
    |con|
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1838
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1839
    con := handlerContext.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1840
    handlerContext := suspendedContext := nil.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1841
    con unwindAndRestart
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1842
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1843
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1844
     |rslt n|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1845
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1846
     Object errorSignal handle:[:ex |
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1847
	'fixing divisor ...' printCR.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1848
	n := 1.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1849
	ex restart.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1850
     ] do:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1851
	rslt := 5 / n.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1852
     ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1853
     rslt
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1854
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1855
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1856
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1857
restartDo:aBlock
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1858
    "restart the handle:do: but execute the argument, aBlock instead of the
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1859
     original do-block - usually after some repair work is done in handler"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1860
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1861
    |con|
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1862
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1863
    con := handlerContext.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1864
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1865
"/    handlerContext unwindThenDo:[
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1866
"/        handlerContext receiver 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1867
"/            handle:(handlerContext argAt:1)
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1868
"/            do:aBlock
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1869
"/    ].
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1870
    handlerContext := suspendedContext := nil.
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1871
    con receiver handlerProtectedBlock:aBlock inContext:con.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1872
    con unwindAndRestart
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1873
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1874
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1875
     |sig rslt|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1876
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1877
     sig := Signal new.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1878
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1879
     sig handle:[:ex |
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1880
	ex restartDo:[ rslt := 999 ]
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1881
     ] do:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1882
	rslt := 0.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1883
	sig raise
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1884
     ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1885
     Transcript showCR:rslt
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1886
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1887
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1888
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1889
     |sig rslt|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1890
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1891
     Object errorSignal handle:[:ex |
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1892
	ex restartDo:[ rslt := 999 ]
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1893
     ] do:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1894
	rslt := nil foo.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1895
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1896
     ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1897
     Transcript showCR:rslt
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1898
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1899
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1900
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1901
     |sig rslt|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1902
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1903
     Object errorSignal handle:[:ex |
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1904
	ex restartDo:[ 'handler' printCR. rslt := nil foo ]
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1905
     ] do:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  1906
	rslt := nil foo.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1907
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1908
     ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1909
     Transcript showCR:rslt
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1910
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1911
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1912
    "Modified: / 8.11.1997 / 18:52:28 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1913
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1914
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1915
resume
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1916
    "Continue after the raise - the raise returns nil"
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1917
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1918
    "/ obsolete (use #proceed), retained for backwards compatibility"
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1919
    "/ no - ANSI defines #resume - sigh
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1920
    "/ <resource:#obsolete>
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1921
    "/
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1922
    "/ self obsoleteMethodWarning:'use #proceed'.
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1923
5984
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1924
    ^ self proceedWith:(self defaultResumeValue)
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1925
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1926
    "Modified: / 2.3.1998 / 10:51:55 / stefan"
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1927
    "Modified: / 7.9.2001 / 13:28:34 / cg"
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1928
!
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1929
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1930
resume:value
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1931
    "Continue after the raise - the raise returns value"
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1932
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1933
    ^ self proceedWith:value
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1934
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1935
    "Modified: / 7.9.2001 / 13:28:49 / cg"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1936
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1937
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1938
resumeWith:value
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1939
    "Continue after the raise - the raise returns value"
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1940
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1941
    "/ obsolete (use #proceedWith:), retained for backwards compatibility
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1942
    "/ no - ANSI defines #resume: - sigh
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1943
    "/<resource:#obsolete>
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1944
    "/
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1945
    "/ self obsoleteMethodWarning:'use #proceedWith:'.   
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1946
    ^ self proceedWith:value
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1947
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1948
    "Modified: / 2.3.1998 / 10:51:48 / stefan"
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1949
    "Modified: / 7.9.2001 / 13:29:26 / cg"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1950
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1951
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1952
return
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1953
    "Continue after the handle:do: - the handle:do: returns nil"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1954
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1955
    |con|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1956
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1957
    con := handlerContext.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1958
    handlerContext := suspendedContext := nil.
5984
2d5c04c9fab6 ANSI; added #defaultResumeValue and #defaultReturnValue.
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1959
    con unwind:(self defaultReturnValue)
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1960
5985
4bffb803f9e8 more ANSI stuff
Claus Gittinger <cg@exept.de>
parents: 5984
diff changeset
  1961
    "Modified: / 7.9.2001 / 13:29:34 / cg"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1962
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1963
5939
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1964
return:value
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1965
    "Continue after the handle:do: - the handle:do: returns value"
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1966
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1967
    |con|
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1968
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1969
    con := handlerContext.
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1970
    handlerContext := suspendedContext := nil.
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1971
    con unwind:value
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1972
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1973
    "Modified: 27.3.1997 / 16:46:51 / cg"
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1974
!
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1975
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1976
returnDoing:aBlock
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1977
    "Continue after the handle:do: - the handle:do: returns aBlock value
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1978
     Be careful when debugging. You cannot see the context with #returnDoing:
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1979
     in the debugger if aBlock raises a signal"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1980
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1981
    |con|
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1982
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1983
    con := handlerContext.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1984
    handlerContext := suspendedContext := nil.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1985
    con unwindThenDo:aBlock
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1986
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1987
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1988
returnWith:value
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1989
    "Continue after the handle:do: - the handle:do: returns value"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1990
5939
cd677568dca6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5933
diff changeset
  1991
    self return:value
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1992
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1993
5570
e6e14f50d721 category change
Claus Gittinger <cg@exept.de>
parents: 5348
diff changeset
  1994
!GenericException methodsFor:'printing & storing'!
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1995
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1996
description
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1997
    "return the description string of the signal"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1998
6248
1898c39ebdfa care for non-string description
Claus Gittinger <cg@exept.de>
parents: 6246
diff changeset
  1999
    |sigDescr|
1898c39ebdfa care for non-string description
Claus Gittinger <cg@exept.de>
parents: 6246
diff changeset
  2000
1898c39ebdfa care for non-string description
Claus Gittinger <cg@exept.de>
parents: 6246
diff changeset
  2001
    sigDescr := signal description.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2002
    (messageText isNil or:[ messageText isString not])
6248
1898c39ebdfa care for non-string description
Claus Gittinger <cg@exept.de>
parents: 6246
diff changeset
  2003
    ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  2004
	^ sigDescr
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2005
    ].
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2006
    (messageText startsWith:Character space) ifTrue:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2007
	^ sigDescr, messageText.
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2008
    ].
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2009
    (messageText endsWith:Character space) ifTrue:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2010
	^ messageText, sigDescr.
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2011
    ].
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2012
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2013
    ^ messageText
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2014
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2015
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2016
      (Error new messageText:'bla') description
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2017
      (Error new messageText:' bla') description
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2018
      (Error new messageText:'bla ') description
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2019
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2020
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2021
    "Modified: / 12.3.1998 / 15:13:28 / stefan"
6859
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
  2022
!
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
  2023
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
  2024
printOn:aStream
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
  2025
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
  2026
    super printOn:aStream.
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
  2027
    aStream nextPut:$(; nextPutAll:self description; nextPut:$)
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2028
! !
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  2029
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2030
!GenericException methodsFor:'private'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2031
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2032
doCallAction
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2033
    "call the action proper 
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2034
     - needed an extra method to have a raise-marked context around
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2035
       ( see implementation of #reject and #proceed)."
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2036
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  2037
    <context: #return>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  2038
    <exception: #raise>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  2039
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
  2040
    "/ thisContext markForRaise. -- same as above pragma
4527
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4521
diff changeset
  2041
    ^ self defaultAction
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2042
!
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2043
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2044
doCallHandler:aHandlerBlock
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2045
    "call the handler proper 
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2046
     - needed an extra method to have a raise-marked context around.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2047
       ( see implementation of #reject and #proceed)."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2048
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  2049
    <context: #return>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  2050
    <exception: #raise>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  2051
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2052
    |val|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2053
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
  2054
    "/ thisContext markForRaise. -- same as above pragma
6158
7fb96896ed4b support 0-arg handler blocks
Claus Gittinger <cg@exept.de>
parents: 6036
diff changeset
  2055
    aHandlerBlock numArgs == 0 ifTrue:[
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2056
        "/ 0-arg handler - not interested in the ex - object
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2057
        val := aHandlerBlock value
6158
7fb96896ed4b support 0-arg handler blocks
Claus Gittinger <cg@exept.de>
parents: 6036
diff changeset
  2058
    ] ifFalse:[
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2059
        "/ 1-arg handler - pass myself as exception argument
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2060
        val := aHandlerBlock value:self.
6158
7fb96896ed4b support 0-arg handler blocks
Claus Gittinger <cg@exept.de>
parents: 6036
diff changeset
  2061
    ].
7fb96896ed4b support 0-arg handler blocks
Claus Gittinger <cg@exept.de>
parents: 6036
diff changeset
  2062
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2063
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2064
     handler fall through - is just like a returnWith:blocks-value
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2065
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2066
    self returnWith:val
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2067
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2068
    "Modified: / 26.7.1999 / 14:41:55 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2069
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2070
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2071
doRaise
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2072
    "search through the context-calling chain for a handle-context 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2073
     to the raising signal, a parent of it, or a SignalSet which includes 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2074
     the raising signal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2075
     If found, ask the receiver for the handler and evaluate
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2076
     it with the receiver exception as argument.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2077
     If no handler is found, perform the default #action method.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2078
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2079
     ATTENTION: the code below depends on being called by #raise or
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2080
     #raiseRequest for proper operation (it skips the sending context)."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2081
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  2082
    <context: #return>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  2083
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2084
    |currentContext|
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2085
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2086
    "is nil a valid originator? If so, we need an extra
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2087
     instanceVariable to record the originator setting"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2088
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2089
    originator isNil ifTrue:[
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2090
        originator := suspendedContext homeReceiver
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2091
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2092
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2093
    signal isExceptionCreator ifFalse:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2094
        "there is something rotten in the state of denmark"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2095
        GenericException raiseWith:signal errorString:'unexpected non-ExceptionCreator in calling context'.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2096
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2097
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2098
    "now, start searching for a handler.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2099
     Start search above the last active handler.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2100
     Skip raise contexts.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2101
     If nil, then there is no handler and we can directly proceed
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2102
     to the unhandled code below."
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2103
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2104
    currentContext := suspendedContext findExceptional.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2105
    [currentContext notNil] whileTrue:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2106
        (currentContext isRaiseContext) ifTrue:[ 
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2107
            |ex1 con1|
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2108
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2109
            "skip all the contexts between the raise and the sender of #handle:do"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2110
            ex1 := currentContext receiver.     "exception, that has been raised"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2111
            con1 := ex1 handlerContext.         "the context of the #handle:do:"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2112
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2113
            con1 isNil ifTrue:[ 
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2114
                "the handlerContext is nil if an exception's default action is performed.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2115
                 Start search at the sending context.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2116
                 Maybe we should better treat a default action like a #handle:do:
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2117
                 at the outest level. But the DebugView currently can't handle this,
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2118
                 because it tries to raise e.g. AbortOperationRequest even if it has bee invoked
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2119
                 by e.g. NoHandlerError"   
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2120
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2121
                (ex1 signal == signal) ifTrue:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2122
                    "the same exception that has been cought by a default action is raised again.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2123
                     don't recurse"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2124
                    ^ self noHandler.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2125
                ].
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2126
            ] ifFalse:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2127
                "skip to the raised exception's handleContext"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2128
                currentContext := con1.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2129
            ].
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2130
            ex1 := con1 := nil.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2131
        ] ifFalse:[ "currentContext is a handleContext"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2132
            |r handler|
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2133
    
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2134
            "ask the the receiver of the #handle:do: or #on:do: or whatever- message for the handler.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2135
             nil is returned, if the signal is not accepted"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2136
            r := currentContext receiver.     "receiver of #handle:do: or #on:do:"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2137
            (r notNil and:[(handler := r handlerForSignal:signal 
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2138
                                         context:currentContext 
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2139
                                         originator:originator) notNil]
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2140
            ) ifTrue:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2141
                "call the handler"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2142
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2143
                "remember the handling signal, sigSet, exception or whatever"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2144
                handlingException := r handlingExceptionInContext:currentContext.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2145
                handlerContext := currentContext.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2146
                currentContext := nil.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2147
                self doCallHandler:handler.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2148
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2149
                "if the handler rejects, we arrive here
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2150
                 continue search for another handler"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2151
                currentContext := handlerContext.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2152
                handler := handlerContext := nil.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2153
            ].
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2154
            r := handler := nil.
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2155
        ].
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2156
        currentContext notNil ifTrue:[
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2157
            currentContext := currentContext findSpecialHandle:true raise:true. "search starts at currentContext sender"
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2158
        ].
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2159
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2160
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2161
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2162
     we arrive here, if either no handler was found, 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2163
     or every handler rejected.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2164
    "
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2165
    ^ self doCallAction
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2166
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2167
    "Created: / 12.5.1996 / 15:09:39 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2168
    "Modified: / 9.11.1997 / 14:48:44 / cg"
4504
173da3e8b629 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 4498
diff changeset
  2169
    "Modified: / 3.8.1999 / 11:20:41 / stefan"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2170
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2171
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2172
!GenericException methodsFor:'raising'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2173
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2174
raise
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2175
    "actually raise a non-proceedable exception"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2176
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  2177
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  2178
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2179
    suspendedContext isNil ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  2180
	suspendedContext := thisContext sender
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2181
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2182
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2183
    proceedable := false.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2184
    ^ self doRaise
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2185
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2186
    "Modified: / 12.5.1996 / 15:09:47 / cg"
4507
c15d849b1ddc Remove unused vars.
Stefan Vogel <sv@exept.de>
parents: 4504
diff changeset
  2187
    "Modified: / 3.8.1999 / 13:33:01 / stefan"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2188
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2189
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2190
raiseRequest
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2191
    "actually raise a proceedable exception."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2192
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  2193
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  2194
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2195
    suspendedContext isNil ifTrue:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  2196
	suspendedContext := thisContext sender
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2197
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2198
6598
6d5c36971981 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6581
diff changeset
  2199
    self mayProceed ifFalse:[ 
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  2200
	StrictRaising ifTrue:[
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  2201
	    "/ proceeding from wrongProceedabilitySignal grants the raiseRequest
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  2202
	    WrongProceedabilityError raiseRequestWith:signal
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  2203
	] ifFalse:[
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  2204
	    'Exception [warning]: raised with wrong proceedability: ' infoPrint.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  2205
	    self class name infoPrintCR.
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  2206
	]
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2207
    ].
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  2208
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2209
    proceedable := true.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2210
    ^ self doRaise
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2211
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2212
    "Modified: / 12.5.1996 / 15:09:44 / cg"
4517
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
  2213
    "Modified: / 4.8.1999 / 08:05:12 / stefan"
5680
7c27d1de0c56 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
  2214
!
7c27d1de0c56 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
  2215
7c27d1de0c56 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
  2216
raiseSignal
7c27d1de0c56 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
  2217
    "actually raise an exception (whatever the proceedability is)."
7c27d1de0c56 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
  2218
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2219
    <context: #return>
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2220
5680
7c27d1de0c56 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
  2221
    self mayProceed ifFalse:[
8070
2fec8e67e119 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8065
diff changeset
  2222
	^ self raise
5680
7c27d1de0c56 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
  2223
    ].
5697
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2224
    ^ self raiseRequest
ce78c7d9ddbd raiseSignal / raiseSignal: / raiseSignal:with:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2225
! !
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2226
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2227
!GenericException methodsFor:'setup'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2228
6945
9536335d243b use setSignal, to avoid conflict with dolphin signals
Claus Gittinger <cg@exept.de>
parents: 6920
diff changeset
  2229
setSignal:aSignal
9536335d243b use setSignal, to avoid conflict with dolphin signals
Claus Gittinger <cg@exept.de>
parents: 6920
diff changeset
  2230
    "set the fields usable for inspection by the handler
9536335d243b use setSignal, to avoid conflict with dolphin signals
Claus Gittinger <cg@exept.de>
parents: 6920
diff changeset
  2231
     - only to be sent from the signal when raising.
9536335d243b use setSignal, to avoid conflict with dolphin signals
Claus Gittinger <cg@exept.de>
parents: 6920
diff changeset
  2232
     CG: added this one to avoid confusion with dolphin signal: (which raises the ex)"
9536335d243b use setSignal, to avoid conflict with dolphin signals
Claus Gittinger <cg@exept.de>
parents: 6920
diff changeset
  2233
9536335d243b use setSignal, to avoid conflict with dolphin signals
Claus Gittinger <cg@exept.de>
parents: 6920
diff changeset
  2234
    signal := aSignal.
9536335d243b use setSignal, to avoid conflict with dolphin signals
Claus Gittinger <cg@exept.de>
parents: 6920
diff changeset
  2235
!
9536335d243b use setSignal, to avoid conflict with dolphin signals
Claus Gittinger <cg@exept.de>
parents: 6920
diff changeset
  2236
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2237
signal:aSignal originator:origin
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2238
    "set the fields usable for inspection by the handler
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2239
     - only to be sent from the signal when raising"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2240
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2241
    signal := aSignal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2242
    originator := origin.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2243
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2244
    "Created: / 23.7.1999 / 13:39:35 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2245
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2246
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2247
signal:aSignal parameter:aParameter errorString:aString suspendedContext:sContext originator:origin
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2248
    "set the fields usable for inspection by the handler
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2249
     - only to be sent from the signal when raising"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2250
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2251
    signal := aSignal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2252
    parameter := aParameter.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2253
    messageText := aString.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2254
    suspendedContext := sContext.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2255
    originator := origin.
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2256
!
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2257
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2258
suspendedContext:sContext errorString:aString
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2259
    "set required fields 
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2260
     - only to be sent from the signal when raising"
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2261
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2262
    messageText := aString.
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2263
    suspendedContext := sContext.
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2264
!
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2265
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2266
suspendedContext:sContext parameter:aParameter
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2267
    "set required fields 
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2268
     - only to be sent from the signal when raising"
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2269
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2270
    parameter := aParameter.
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2271
    suspendedContext := sContext.
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2272
!
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2273
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2274
suspendedContext:sContext parameter:aParameter errorString:aString
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2275
    "set required fields 
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2276
     - only to be sent from the signal when raising"
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2277
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2278
    parameter := aParameter.
8313
2aa626e8e404 Fix do not execute an exception handler inside the do-block, when the
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
  2279
    messageText := aString.
6430
9a1580465dd2 better impl. of #deferAfter:
Claus Gittinger <cg@exept.de>
parents: 6426
diff changeset
  2280
    suspendedContext := sContext.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2281
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2282
6220
1b9aa02b02ef isException query
Claus Gittinger <cg@exept.de>
parents: 6200
diff changeset
  2283
!GenericException methodsFor:'testing'!
1b9aa02b02ef isException query
Claus Gittinger <cg@exept.de>
parents: 6200
diff changeset
  2284
8065
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2285
isError
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2286
    ^ false
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2287
!
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2288
6220
1b9aa02b02ef isException query
Claus Gittinger <cg@exept.de>
parents: 6200
diff changeset
  2289
isException
1b9aa02b02ef isException query
Claus Gittinger <cg@exept.de>
parents: 6200
diff changeset
  2290
    ^ true
1b9aa02b02ef isException query
Claus Gittinger <cg@exept.de>
parents: 6200
diff changeset
  2291
1b9aa02b02ef isException query
Claus Gittinger <cg@exept.de>
parents: 6200
diff changeset
  2292
    "Created: / 17.11.2001 / 18:37:27 / cg"
8065
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2293
!
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2294
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2295
isOpenError
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2296
    ^ false
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2297
!
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2298
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2299
isStreamError
23355398af34 isOpenError, isStreamError and isError queries added
Claus Gittinger <cg@exept.de>
parents: 7808
diff changeset
  2300
    ^ false
6220
1b9aa02b02ef isException query
Claus Gittinger <cg@exept.de>
parents: 6200
diff changeset
  2301
! !
1b9aa02b02ef isException query
Claus Gittinger <cg@exept.de>
parents: 6200
diff changeset
  2302
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2303
!GenericException class methodsFor:'documentation'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2304
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2305
version
8466
ce104835047e Fix class methods raiseSignal:
Stefan Vogel <sv@exept.de>
parents: 8390
diff changeset
  2306
    ^ '$Header: /cvs/stx/stx/libbasic/GenericException.st,v 1.89 2004-08-07 18:42:36 stefan Exp $'
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2307
! !
6859
5ef85865e8db Print exception description with #printOn:
Stefan Vogel <sv@exept.de>
parents: 6630
diff changeset
  2308
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2309
GenericException initialize!