GenericException.st
author Stefan Vogel <sv@exept.de>
Fri, 21 Jan 2000 20:59:45 +0100
changeset 5197 14331ce13d51
parent 5061 cd1fbfdf888a
child 5259 cda0ce95054d
permissions -rw-r--r--
Fix detection of active handlers (change for class based exceptions)
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
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
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
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
Object subclass:#GenericException
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
    14
	instanceVariableNames:'signal parameter errorString suspendedContext handlerContext
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
    15
		rejected originator proceedable handlingException'
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
    16
	classVariableNames:''
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
    17
	poolDictionaries:''
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
    18
	category:'Kernel-Exceptions'
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
GenericException class instanceVariableNames:'NotifierString'
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
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
 The following class instance variables are inherited by this class:
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
    26
	Object - 
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
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
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
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    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
    49
    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
    50
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    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
    52
    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
    53
    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
    54
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    55
        reject          - don't handle this signal;
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    56
                          another handler will be searched for, 
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    57
                          upper in the calling hierarchy
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    59
        proceed         - return from the Signal>>raise, with nil as value
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    61
        proceedWith:val - same, but return val from Signal>>raise
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    63
        return          - return from the Signal>>handle:do:, with nil as value
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    65
        returnWith:val  - same, but return val from Signal>>handle:do:
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    66
                          (this is also the handlers default, 
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    67
                           if it falls through; taking the handlerBlocks value
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    68
                           as return value)
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    70
        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
    71
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    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
    73
    where the Signal was raised, where the handler is, the signal which caused
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    the error and the errorString passed when the signal was raised. Also, an optional
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    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
    76
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    [instance variables:]
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    78
        signal           <Signal>     the signal which caused the exception
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    80
        parameter        <Object>     a parameter (if any) which was passed when raising
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    81
                                      the signal (only if raised with #raiseWith:aParameter)
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    83
        errorString      <String>     an errorString 
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    84
                                      (usually the signals own errorString, but sometimes
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    85
                                       changed explicitely in #raiseWith:errorString:)
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    87
        suspendedContext <Context>    the context in which the raise occured
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    89
        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
    90
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    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
    92
    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
    93
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    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
    95
    possible.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    For example, to get the typical C++ behavior, use:
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
    97
        Exception emergencyHandler:[:ex | Smalltalk exitWithCoreDump]
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    [see also:]
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   100
        Signal  SignalSet QuerySignal
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   101
        Context Block
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   102
        Object DebugView
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   103
        (``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
   104
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    [author:]
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   106
        Claus Gittinger
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
!
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
examples
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    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
   113
    section (CodingExamples).
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    The emergencyHandler stuff is very useful, to prevent endUser applications
4554
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4548
diff changeset
   116
    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
   117
"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
!GenericException class methodsFor:'initialization'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
initialize 
4519
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   123
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   124
    NotifierString := 'unknown exception'.
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   125
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   126
    "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
   127
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
!GenericException class methodsFor:'instance creation'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
signal:aSignal originator:origin
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    "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
   133
     - 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
   134
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    "{ Pragma: +inlineNew }"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    ^ (self basicNew) signal:aSignal originator:origin.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    "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
   140
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
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
   143
    "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
   144
     - 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
   145
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    "{ Pragma: +inlineNew }"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    ^ (self basicNew)
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   149
        signal:aSignal 
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   150
        parameter:aParameter 
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   151
        errorString:aString 
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   152
        suspendedContext:sContext 
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   153
        originator:origin.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
!GenericException class methodsFor:'Signal constants'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
4517
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   158
noHandlerError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   159
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   160
    ^ NoHandlerError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   161
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   162
    "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
   163
!
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   164
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   165
proceedError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   166
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   167
    ^ ProceedError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   168
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   169
    "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
   170
!
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   171
4519
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   172
recursiveExceptionError
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    "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
   174
4519
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   175
    ^ RecursiveExceptionError
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
    "Created: / 4.8.1999 / 09:05:06 / stefan"
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   178
!
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
recursiveExceptionSignal
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   181
    "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
   182
     This is for backward compatinility. Use recursiveExceptionError"
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   183
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   184
    ^ RecursiveExceptionError
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   185
fb4904d6787b Implement RecursiveExceptionError. as class based exception.
Stefan Vogel <sv@exept.de>
parents: 4517
diff changeset
   186
    "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
   187
!
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   188
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   189
wrongProceedabilityError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   190
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   191
    ^ WrongProceedabilityError
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   192
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
   193
    "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
   194
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   196
!GenericException class methodsFor:'accessing'!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   197
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   198
notifierString:aString
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   199
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   200
    NotifierString := aString
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   201
! !
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   202
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
!GenericException class methodsFor:'compatibility - accessing'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
errorString
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   206
    "#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
   207
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   208
    ^ self description
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
handlerBlock
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    "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
   213
     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
   214
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
    ^ nil
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    "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
   218
    "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
   219
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   221
!GenericException class methodsFor:'compatibility - defaults'!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   222
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   223
emergencyHandler
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   224
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   225
    ^ NoHandlerError emergencyHandler.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   226
!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   227
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   228
emergencyHandler:aOneArgBlock
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   229
    "set the handler used for unhandled exceptions.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   230
     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
   231
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   232
    ^ NoHandlerError emergencyHandler:aOneArgBlock.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   233
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   234
    "ST-80 behavior of first showing a notifier:
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   235
     (I prefer to get right into the debugger, though)
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   236
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   237
     Exception
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   238
        emergencyHandler:
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   239
            [:ex | self errorNotify:ex errorString ]
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   240
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   241
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   242
    "ST-X behavior of going right into the debugger:
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   243
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   244
     Exception
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   245
        emergencyHandler:nil
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   246
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   247
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   248
    "automatically aborting current operation, on error:
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   249
     (may be useful for end-user apps; make certain, 
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   250
      you have abortSignal handlers at appropriate places)
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   251
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   252
     Exception
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   253
        emergencyHandler:
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   254
            [:ex | Object abortSignal raise. ex return. ]
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   255
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   256
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   257
    "finally, traditional language system behavior; dump core ;-)
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   258
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   259
     Exception
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   260
        emergencyHandler:
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   261
            [:ex | Smalltalk exitWithCoreDump. ]
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   262
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   263
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   264
    "Modified: 15.1.1997 / 20:49:06 / cg"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   265
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   266
! !
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   267
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
!GenericException class methodsFor:'compatibility - queries'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
accepts:aSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    "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
   272
     (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
   273
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    |s|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
4527
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4521
diff changeset
   276
    self == aSignal ifTrue:[^ true].
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    aSignal isQuerySignal ifTrue:[^ false].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    s := aSignal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
    [s notNil] whileTrue:[
4527
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4521
diff changeset
   281
        self == s ifTrue:[^ true].
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4521
diff changeset
   282
        s := s parent
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
    ^ false
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    "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
   287
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
4676
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   289
exception:anExceptionOrSignal isHandledIn:aContext
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   290
    "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
   291
     contextChain starting with aContext."
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   292
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   293
    |con r|
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   294
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   295
    con := Context findFirstSpecialHandle:true raise:false.
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   296
    [con notNil] whileTrue:[
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   297
        ((r := con receiver) notNil
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   298
         and:[(r handlerForSignal:anExceptionOrSignal context:con originator:nil) notNil]
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   299
        ) ifTrue:[
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   300
            "found a handler context"
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   301
            ^ true
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   302
        ].
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   303
        con := con findSpecialHandle:true raise:false.
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   304
    ].
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   305
    ^ false
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   306
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   307
!
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   308
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
handlerForSignal:signal context:theContext originator:originator
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    "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
   311
     The block is retrieved from aContext.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
     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
   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
    (theContext selector ~~ #'handle:from:do:'
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
     or:[(theContext argAt:2) == originator]) ifTrue:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   317
        (self == signal or:[self accepts:signal]) ifTrue:[
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   318
            ^ theContext argAt:1
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   319
        ]
4481
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
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
    ^ nil
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
    "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
   325
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   327
handlerProtectedBlock:doBlock inContext:context
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   328
    "set the handlerProtectedBlock in context"
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   329
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   330
    context selector == #handle:do: ifTrue:[
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   331
        context argAt:2 put:doBlock.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   332
    ] ifFalse:[context selector == #handle:from:do: ifTrue:[
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   333
        context argAt:3 put:doBlock.
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   334
    ]].
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   335
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   336
!
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
   337
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
handlingExceptionInContext:theContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
    "answer the handling exception from aContext."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
    (theContext selector == #'handle:from:do:'
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
     or:[theContext selector == #'handle:do:']) ifTrue:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   343
        ^ theContext receiver
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
    ^ nil
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
inheritsFrom:anotherSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    "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
   351
     (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
   352
     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
   353
     the receiver is identical to anotherSignal."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
    self == anotherSignal ifTrue:[^ false].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
    ^ anotherSignal accepts:self
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
    "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
   359
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
isHandled
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
    "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
   363
     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
   364
     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
   365
4676
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   366
    ^ 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
   367
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
    "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
   369
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
isHandledIn:aContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
    "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
   373
     contextChain starting with aContext."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
4676
5d469e2da40a common code for isHandled
Claus Gittinger <cg@exept.de>
parents: 4632
diff changeset
   375
    ^ self exception:self isHandledIn:aContext
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
!
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
isQuerySignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
    "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
   380
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
    ^ 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
    "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
   384
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
isSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    "return true, if the receiver is some kind of signal;
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
     true returned here - the method is redefined from Object."
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
    ^ true
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
    "Created: / 23.7.1999 / 13:49:59 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
mayProceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    "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
   397
     the execution where the exception occured.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
     Subclasses may redefine this."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
    ^ true
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
    "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
   404
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
parent
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
    "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
   408
     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
   409
     existing Signals."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
    self == GenericException ifTrue:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   412
        ^ nil
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
    ^ self superclass
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
    "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
   418
    "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
   419
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
!GenericException class methodsFor:'compatibility - raising'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
new
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   424
    "{ Pragma: +inlineNew }"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
    ^ self basicNew signal:self.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
    "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
   429
    "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
   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
newException
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
    ^ self new
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
    "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
   437
    "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
   438
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
newExceptionFrom:originator
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
    "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
   442
     Set the originator.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
     Subclasses may redefine this method"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
    ^ self new originator:originator
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
    "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
   448
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
raise
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
    "raise a signal nonproceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
     The signals notifierString is used as errorString."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   454
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   455
4538
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   456
    ^ self newException 
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   457
        suspendedContext:thisContext sender;
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   458
        raise
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
    "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
   461
    "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
   462
    "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
   463
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
raiseErrorString:aString
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
    "raise a signal nonproceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
     The argument is used as errorString."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   469
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   470
4538
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   471
    ^ self newException 
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   472
        suspendedContext:thisContext sender;
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   473
        errorString:aString;
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   474
        raise.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
    "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
   477
    "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
   478
    "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
   479
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
raiseFrom:something
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
    "raise a signal nonproceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
     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
   484
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   485
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   486
4538
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   487
    ^ (self newExceptionFrom:something) 
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   488
        suspendedContext:thisContext sender;
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   489
        parameter:something;
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   490
        raise
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
    "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
   493
    "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
   494
    "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
   495
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
raiseRequest
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
    "raise a signal proceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
     The signals notifierString is used as errorString."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   501
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   502
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   503
    ^ self newException 
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   504
        suspendedContext:thisContext sender;
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   505
        raiseRequest.
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
    "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
   508
    "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
   509
    "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
   510
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
4758
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   512
raiseRequestErrorString:aString
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   513
    "raise a signal proceedable.
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   514
     The argument, aString is used as errorString."
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   515
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   516
    <context: #return>
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   517
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   518
    ^ self newException 
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   519
        suspendedContext:thisContext sender;
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   520
        errorString:aString;
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   521
        raiseRequest
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   522
!
91b5a25f29c5 added #raiseRequestErrorString
Claus Gittinger <cg@exept.de>
parents: 4676
diff changeset
   523
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
raiseRequestFrom:something
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
    "raise a signal proceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
     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
   527
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   528
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   529
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   530
    ^ (self newExceptionFrom:something) 
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   531
        suspendedContext:thisContext sender;
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   532
        parameter:something;
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   533
        raiseRequest.
4481
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
    "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
   536
    "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
   537
    "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
   538
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
raiseRequestWith:aParameter
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
    "raise a signal proceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
     The signals notifierString is used as errorString."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   544
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   545
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   546
    ^ self newException 
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   547
        suspendedContext:thisContext sender;
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   548
        parameter:aParameter;
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   549
        raiseRequest.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
    "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
   552
    "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
   553
    "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
   554
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
raiseRequestWith:aParameter errorString:aString
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
    "raise a signal proceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
     The argument, aString is used as errorString."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   560
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   561
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   562
    ^ self newException 
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   563
        suspendedContext:thisContext sender;
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   564
        parameter:aParameter; 
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   565
        errorString:aString;
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   566
        raiseRequest
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
    "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
   569
    "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
   570
    "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
   571
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
raiseRequestWith:aParameter errorString:aString in:aContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
    "raise a signal proceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
     The argument, aString is used as errorString.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
     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
   577
     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
   578
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   579
    ^ self newException 
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   580
        parameter:aParameter; 
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   581
        errorString:aString;
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   582
        suspendedContext:aContext;
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   583
        raiseRequest
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
    "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
   586
    "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
   587
    "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
   588
!
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
raiseWith:aParameter
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
    "raise a signal nonproceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
     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
   593
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   594
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   595
4538
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   596
    ^ self newException 
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   597
        suspendedContext:thisContext sender;
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   598
        parameter:aParameter;
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   599
        raise.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
    "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
   602
    "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
   603
    "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
   604
!
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
raiseWith:aParameter errorString:aString
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
    "raise a signal nonproceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
     The argument, aString is used as errorString, aParameter is passed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
     as exception parameter."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   611
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
   612
4538
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   613
    ^ self newException 
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   614
        suspendedContext:thisContext sender;
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   615
        parameter:aParameter;
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   616
        errorString:aString;
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   617
        raise.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
    "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
   620
    "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
   621
    "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
   622
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
raiseWith:aParameter errorString:aString in:aContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
    "raise a signal nonproceedable.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
     The argument, aString is used as errorString, aParameter is passed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
     as exception parameter.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
     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
   629
     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
   630
4538
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   631
    ^ self newException 
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   632
          parameter:aParameter; 
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   633
          errorString:aString;
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   634
          suspendedContext:aContext; 
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   635
          raise.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
    "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
   638
    "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
   639
    "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
   640
! !
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
!GenericException class methodsFor:'compatibility - save evaluation'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
catch:aBlock
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   645
    "evaluate the argument, aBlock.
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   646
     If the receiver-signal is raised during evaluation, abort
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   647
     the evaluation and return true; otherwise return false. 
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   648
     This is the catch & throw mechanism found in other languages,
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   649
     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
   650
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   651
    |raiseOccurred|
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   653
    raiseOccurred := false.
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   654
    self handle:[:ex | raiseOccurred := true. ex return] do:aBlock.
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   655
    ^ raiseOccurred
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   657
    "
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   658
     Object messageNotUnderstoodSignal catch:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   659
        123 size open   
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   660
     ]
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   661
    "
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   663
    "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
   664
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   666
handle:handleBlock do:aBlock
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
    "evaluate the argument, aBlock.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
     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
   669
     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
   670
     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
   671
     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
   672
     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
   673
     aBlock."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   675
    <context: #return>
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
   676
    <exception: #handle>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
   677
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   678
    "/ thisContext markForHandle. -- same as above pragma
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   679
    ^ 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
   680
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   681
    "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   682
     Object messageNotUnderstoodSignal handle:[:ex |
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   683
        'oops' printNL.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   684
        ex return
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   685
     ] do:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   686
        123 size open   
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   687
     ]
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   688
     "
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   690
     "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   691
      |num|
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   692
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   693
      num := 0.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   694
      Number divisionByZeroSignal handle:[:ex |
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   695
          'oops' printNL.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   696
          ex return
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   697
      ] do:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   698
          123 / num   
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   699
      ]
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   700
     "
4481
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
    "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
   703
    "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
   704
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
handle:handleBlock from:anObject do:aBlock
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
    "evaluate the argument, aBlock.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
     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
   709
     and the exception originated from anObject,
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
     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
   711
     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
   712
     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
   713
     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
   714
     aBlock."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   716
    <context: #return>
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
   717
    <exception: #handle>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
   718
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   719
    "/ thisContext markForHandle. -- same as above pragma
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   720
    ^ 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
   721
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   722
    "
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   723
     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
   724
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   725
     |o1 o2|
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   727
     o1 := 123.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   728
     o2 := nil.
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   729
     Object messageNotUnderstoodSignal 
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   730
         handle:
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   731
                [:ex |
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   732
                    'oops' printNL.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   733
                    ex proceed
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   734
                ] 
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   735
         from:o1
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   736
         do:
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   737
                [
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   738
                    o1 open.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   739
                    o2 open
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   740
                ]
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
   741
    "
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
    "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
   744
    "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
   745
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
ignoreIn:aBlock
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   748
    "evaluate the argument, aBlock.
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   749
     Ignore the receiver-signal during evaluation - i.e. simply
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   750
     continue. 
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   751
     This makes only sense for some signals, such as UserInterrupt
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   752
     or AbortSignal, because continuing after an exception without any cleanup
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   753
     often leads to followup-errors."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   755
    ^ 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
   756
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   757
    "
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   758
     Object messageNotUnderstoodSignal ignoreIn:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   759
        123 size open   
4496
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   760
     ]
28f3f57dbe60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   761
    "
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
    "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
   764
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   766
!GenericException class methodsFor:'compatibility - signal creation'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   768
newSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
    "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
   770
     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
   771
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
    ^ self newSignalMayProceed:self mayProceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
    "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
   775
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
newSignalMayProceed:proceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
    "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
   779
     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
   780
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
    ^ (Signal basicNew) mayProceed:proceed;
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   782
                    notifierString:NotifierString;
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
   783
                            parent:self
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
    "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
   786
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   788
!GenericException class methodsFor:'printing'!
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   790
description
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   791
    "return the notifier string.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   792
     If the notifier string starts with space, prepend
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   793
     the parents notifier string.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   794
     Subclasses may redefine this method."
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   796
    NotifierString isNil ifTrue:[
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   797
        ^ self name asString
4606
21bf9124f4ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   798
    ].
21bf9124f4ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   799
    (NotifierString startsWith:Character space) ifTrue:[
21bf9124f4ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   800
        ^ self parent description, NotifierString
21bf9124f4ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   801
    ].
21bf9124f4ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   802
    ^ NotifierString
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   804
    "
4606
21bf9124f4ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4564
diff changeset
   805
     Object errorSignal description
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
   808
    "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
   809
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   811
!GenericException class methodsFor:'useful handlers'!
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   812
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   813
abortingEmergencyHandler
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   814
    "return a block (usable as an emergency handler), 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   815
     which aborts after showing a warnBox.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   816
     This is useful for endUser applications.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   817
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   818
     WARNING: this method belongs to NoHandlerError, and may eventually be
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   819
     moved there - it is (for now) left here for backward compatibility."
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   820
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   821
    ^ [:ex | self warn:'Error: ' , ex errorString.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   822
             AbortSignal raise 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   823
      ]
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   824
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   825
    "test with (try a few halts or CTRL-C's):
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   826
     NoHandlerError emergencyHandler:(NoHandlerError abortingEmergencyHandler)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   827
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   828
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   829
    "back with:
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   830
     NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandler)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   831
     NoHandlerError emergencyHandler:nil
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   832
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   833
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   834
    "Created: 15.1.1997 / 20:13:06 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   835
    "Modified: 15.1.1997 / 20:15:02 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   836
!
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   837
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   838
dumpingEmergencyHandler
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   839
    "return a block (usable as an emergency handler), 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   840
     which dumps the stackBacktrace to a trace file and
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   841
     aborts after showing a warnBox.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   842
     This is useful, for endUser application, which are still being
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   843
     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
   844
     from time to time).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   845
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   846
     Notice:
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   847
         The code below is just an example; you may want to change the
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   848
         name of the error-file in your application
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   849
         (but please: copy the code; do not modify here)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   850
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   851
     WARNING: this method belongs to NoHandlerError, and may eventually be
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   852
     moved there - it is (for now) left here for backward compatibility."
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   853
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   854
    ^ [:ex | 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   855
             |str printedException|
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   856
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   857
             ex signal == NoHandlerError ifTrue:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   858
                printedException := ex parameter.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   859
             ] ifFalse:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   860
                printedException := ex
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   861
             ].
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   862
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   863
             "/ user interruption is handled specially:
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   864
             "/ allow user to choose between proceeding or aborting
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   865
             "/ but never dump that information to the file.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   866
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   867
             printedException signal == Object userInterruptSignal ifTrue:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   868
                  (self confirm:'abort current action ?') ifTrue:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   869
                      AbortSignal raise
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   870
                  ].
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   871
                  ex proceedWith:nil
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   872
             ].
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   873
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   874
             "/
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   875
             "/ dump it to 'errorTrace.stx'
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   876
             "/
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   877
             str := 'errorTrace.stx' asFilename appendingWriteStream.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   878
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   879
             str nextPutLine:('******************************* '
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   880
                              , AbsoluteTime now printString
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   881
                              , ' *******************************').
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   882
             str cr.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   883
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   884
             str nextPutLine:('** Error: ' , printedException errorString).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   885
             str nextPutLine:('** Signal: ' , printedException signal printString).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   886
             str nextPutLine:('** Parameter: ' , printedException parameter printString).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   887
             str nextPutLine:('** Process: ' , Processor activeProcess printString).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   888
             str nextPutLine:('** Backtrace:').
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   889
             str cr.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   890
        
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   891
             printedException suspendedContext fullPrintAllOn:str.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   892
             str cr.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   893
             str cr.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   894
             str close.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   895
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   896
             "/ send a line to stdErr
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   897
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   898
             ('[warning]: ignored error: ' , printedException errorString) errorPrintCR.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   899
             ('[warning]:    error information appended to ''errorTrace.stx''') errorPrintCR.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   900
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   901
             AbortSignal raise 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   902
      ]
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   903
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   904
    "test with (try a few halts or CTRL-C's):
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   905
     NoHandlerError emergencyHandler:(NoHandlerError dumpingEmergencyHandler)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   906
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   907
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   908
    "back with:
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   909
     NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandler)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   910
     NoHandlerError emergencyHandler:nil
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   911
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   912
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   913
    "Created: / 15.1.1997 / 20:14:52 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   914
    "Modified: / 24.1.1997 / 20:36:21 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   915
    "Modified: / 4.8.1999 / 08:11:20 / stefan"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   916
!
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   917
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   918
mailingEmergencyHandler
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   919
    "return a block (usable as an emergency handler), 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   920
     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
   921
     This is useful, for endUser application, which are still being
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   922
     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
   923
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   924
     Notice: the stuff here is a demonstration only; it should be modified
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   925
             for your particular environment ...
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   926
             ... but please: copy the code and modify there;
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   927
             leave the stuff below as it is.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   928
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   929
     WARNING: this method belongs to NoHandlerError, and may eventually be
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   930
     moved there - it is (for now) left here for backward compatibility."
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   931
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   932
    ^ [:ex | 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   933
            |str printedException doMail emergencyMailReceiver pipe|
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   934
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   935
            ex signal == NoHandlerError ifTrue:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   936
               printedException := ex parameter.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   937
            ] ifFalse:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   938
               printedException := ex
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   939
            ].
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   940
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   941
             "/ user interruption is handled specially:
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   942
             "/ allow user to choose between proceeding or aborting
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   943
             "/ but never dump that information to the file.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   944
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   945
             printedException signal == Object userInterruptSignal ifTrue:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   946
                  (self confirm:'abort current action ?') ifTrue:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   947
                      AbortSignal raise
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   948
                  ].
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   949
                  ex proceedWith:nil
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   950
             ].
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   951
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   952
            "/ somehow get the name of the guy to receive the mail
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   953
            "/ you have to implement that yourself.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   954
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   955
            "/ emergencyMailReceiver := OneOfYourClass getEmergencyMailReceiver.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   956
            emergencyMailReceiver := OperatingSystem getLoginName.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   957
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   958
            emergencyMailReceiver isNil ifTrue:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   959
                self warn:(printedException errorString 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   960
                           , '\\No mailing to service people possible.') withCRs.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   961
                doMail := false.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   962
            ] ifFalse:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   963
                doMail := self confirm:(printedException errorString 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   964
                                        , '\\Mail error information to the service people (' 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   965
                                        , emergencyMailReceiver , ') ?') withCRs
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   966
            ].
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   967
            doMail ifTrue:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   968
                str := '' writeStream.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   969
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   970
                str nextPutLine:('Error notification from '
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   971
                                , OperatingSystem getLoginName
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   972
                                , '@'
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   973
                                , OperatingSystem getHostName).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   974
                str cr.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   975
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   976
                str nextPutLine:('Time: ' , AbsoluteTime now printString).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   977
                str nextPutLine:('Error: ', printedException errorString).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   978
                str nextPutLine:('Signal: ', printedException signal printString).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   979
                str nextPutLine:('Parameter: ', printedException parameter printString).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   980
                str nextPutLine:('Process: ', Processor activeProcess printString).
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   981
                str nextPutLine:'Backtrace:'.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   982
                str cr.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   983
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   984
                printedException suspendedContext fullPrintAllOn:str.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   985
                str cr;cr.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   986
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   987
                str close.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   988
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   989
                pipe := PipeStream 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   990
                            writingTo:'mail ', emergencyMailReceiver.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   991
                pipe notNil ifTrue:[
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   992
                    pipe nextPutLine:'Subject: automatic error report'.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   993
                    pipe nextPutAll:str contents.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   994
                    pipe cr.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   995
                    pipe close.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   996
                ]
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   997
             ].
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   998
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
   999
             AbortSignal raise 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1000
      ]
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1001
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1002
    "test with (try a few halts or CTRL-C's):
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1003
     NoHandlerError emergencyHandler:(Exception mailingEmergencyHandler)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1004
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1005
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1006
    "back with:
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1007
     NoHandlerError emergencyHandler:(Exception notifyingEmergencyHandler)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1008
     NoHandlerError emergencyHandler:nil
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1009
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1010
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1011
    "Created: / 15.1.1997 / 20:14:52 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1012
    "Modified: / 15.1.1997 / 21:10:28 / cg"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1013
    "Modified: / 4.8.1999 / 08:11:26 / stefan"
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1014
!
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1015
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1016
notifyingEmergencyHandler
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1017
    "return a block (usable as an emergency handler for exceptions), 
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1018
     which does errorNotification before going into the debugger.
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1019
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1020
     WARNING: this method belongs to NoHandlerError, and may eventually be
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1021
     moved there - it is (for now) left here for backward compatibility."
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1022
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1023
    ^ [:ex | nil errorNotify:ex errorString from:ex suspendedContext ]
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1024
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1025
    "test with (try a few halts or CTRL-C's):
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1026
     Exception emergencyHandler:(Exception notifyingEmergencyHandler)
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1027
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1028
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1029
    "back with:
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1030
     NoHandlerError emergencyHandler:nil
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1031
    "
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1032
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1033
    "Modified: 15.1.1997 / 20:15:12 / cg"
5058
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1034
!
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1035
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1036
notifyingEmergencyHandlerForUserProcesses
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1037
    "return a block (usable as an emergency handler for exceptions), 
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1038
     which does errorNotification before going into the debugger,
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1039
     but only for exceptions occurring in user processes;
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1040
     systemProcesses are not debugged.
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1041
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1042
     WARNING: this method belongs to NoHandlerError, and may eventually be
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1043
     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
  1044
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1045
    ^ [:ex | 
5059
a217f2821e7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5058
diff changeset
  1046
a217f2821e7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5058
diff changeset
  1047
        |theException|
a217f2821e7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5058
diff changeset
  1048
5058
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1049
        Processor activeProcessIsSystemProcess ifTrue:[
5061
cd1fbfdf888a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5060
diff changeset
  1050
            'EmergencyHandler [info]: exception cought: ' errorPrint.
5059
a217f2821e7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5058
diff changeset
  1051
            ex signal == NoHandlerError ifTrue:[
a217f2821e7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5058
diff changeset
  1052
                theException := ex parameter.
a217f2821e7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5058
diff changeset
  1053
            ] ifFalse:[
a217f2821e7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5058
diff changeset
  1054
                theException := ex
a217f2821e7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5058
diff changeset
  1055
            ].
a217f2821e7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5058
diff changeset
  1056
            theException errorString errorPrintCR.
5058
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1057
            AbortSignal raise
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1058
        ] ifFalse:[
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1059
            nil errorNotify:ex errorString from:ex suspendedContext
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1060
        ]
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1061
      ]
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1062
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1063
    "test with (try a few halts or CTRL-C's):
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1064
     Exception emergencyHandler:(Exception notifyingEmergencyHandler)
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1065
    "
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1066
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1067
    "back with:
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1068
     NoHandlerError emergencyHandler:nil
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1069
    "
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1070
42e732f3497c added another useful handler
Claus Gittinger <cg@exept.de>
parents: 4936
diff changeset
  1071
    "Modified: 15.1.1997 / 20:15:12 / cg"
4936
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1072
! !
bc943fef0d96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4758
diff changeset
  1073
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1074
!GenericException methodsFor:'accessing'!
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
creator
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1077
    "return the creator of the exception"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1078
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1079
    ^ signal
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1080
!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1081
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
errorString 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
    "return the errorString passsed with the signal raise
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1084
     (or nil, if there was none).
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1085
     #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
  1086
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1087
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1088
    ^ self description
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
    "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
  1091
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
errorString:aString 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
    "set the errorString.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
     If it starts with a space, the signals errorString is prepended,
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1096
     if it ends with a space, it is appended.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1097
     #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
  1098
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
    errorString := aString
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
    "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
  1102
    "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
  1103
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
handlerContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
    "return the context of the handler"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
    ^ handlerContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
4483
55530226d243 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4481
diff changeset
  1111
handlingException
55530226d243 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4481
diff changeset
  1112
    "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
  1113
     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
  1114
     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
  1115
     (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
  1116
4483
55530226d243 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4481
diff changeset
  1117
    ^ handlingException
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1120
isResumable
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1121
    "return true, if the exception is resumable"
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1122
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1123
    ^ proceedable
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1124
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1125
    "Modified: / 2.3.1998 / 12:20:43 / stefan"
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1126
!
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1127
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1128
messageText:aString 
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1129
    "set the messageText.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1130
     If it starts with a space, the signals errorString is prepended,
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1131
     if it ends with a space, it is appended."
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1132
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1133
    errorString := aString
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1134
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1135
    "Created: / 5.3.1998 / 16:45:29 / stefan"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1136
    "Modified: / 12.3.1998 / 15:30:45 / stefan"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1137
!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1138
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
originator 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
    "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
  1141
     (or nil, if there was none)"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
    ^ originator
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1144
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1145
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
originator:anObject 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1147
    "set the originator"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
    originator := anObject
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
    "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
  1152
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
parameter
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
    "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
  1156
     (or nil, if there was none)"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1157
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
    ^ parameter
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
parameter:anObject
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
    "set the parameter of the exception"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
    parameter := anObject
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
    "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
  1167
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1168
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1169
rejected
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
    "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
  1171
     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
  1172
     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
  1173
     (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
  1174
     rejected).
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
     Currently only used to change the 'unhandled-exception' errorString 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1176
     into 'rejected-exception' for information).
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1177
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1179
    ^ rejected == true
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1180
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1182
signal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1183
    "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
  1184
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
    ^ signal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1186
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1187
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
signal:aSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
    "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
  1190
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1191
    signal := aSignal
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1192
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
    "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
  1194
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1195
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
suspendedContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
    "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
  1198
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1199
    ^ suspendedContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1200
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1201
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1202
suspendedContext:something
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1203
    "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
  1204
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
    suspendedContext := something.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1206
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1207
    "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
  1208
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1209
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1210
willProceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1211
    "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
  1212
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1213
    ^ self isResumable
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1214
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
    "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
  1216
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1218
!GenericException methodsFor:'copying'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1220
postCopy
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1221
    "set the internal state to nil"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1222
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1223
    suspendedContext := handlerContext := rejected := nil
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1224
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
    "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
  1226
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
!GenericException methodsFor:'default actions'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1229
4527
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4521
diff changeset
  1230
defaultAction
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1231
    "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
  1232
     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
  1233
     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
  1234
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1235
     The default is to evaluate the signal's handlerBlock or 
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1236
     to raise the noHandlerSignal.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
     Subclasses may redefine this."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1239
    |handlerBlock|
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1241
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
     try per signal handler
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1243
    "
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1244
    (handlerBlock := signal handlerBlock) notNil ifTrue:[
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1245
        "... and call it"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1246
        ^ handlerBlock value:self.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1247
    ].
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1248
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1249
    "/ if its a querySignal, ignore it
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1250
    signal isQuerySignal ifTrue:[^ nil].
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1251
    ^ self noHandler.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1252
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1253
    "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
  1254
    "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
  1255
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1256
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1257
mayProceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1258
    "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
  1259
     the execution where the exception occured.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1260
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
     Subclasses may redefine this."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1262
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1263
    ^ signal mayProceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1264
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1265
    "Created: / 23.7.1999 / 14:48:26 / stefan"
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1266
!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1267
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1268
noHandler
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1269
    "raise the NoHandlerError.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1270
     NohandlerError redefines this method to avoid recursive invocations"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1271
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1272
    <context: #return>
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1273
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1274
    |msg|
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1275
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1276
    rejected == true ifTrue:[
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1277
        msg := 'unhandled (rejected)'
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1278
    ] ifFalse:[
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1279
        msg := 'unhandled'
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1280
    ].
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1281
    msg := msg , ' exception: (' , self errorString , ')'.
4564
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1282
    self mayProceed ifTrue:[
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1283
        ^ NoHandlerError 
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1284
              raiseRequestWith:self 
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1285
              errorString:msg
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1286
              in:suspendedContext.
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1287
    ].
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1288
    NoHandlerError 
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1289
          raiseWith:self 
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1290
          errorString:msg
5401b0d1a6e3 NoHandlerSignal proceedability
Stefan Vogel <sv@exept.de>
parents: 4562
diff changeset
  1291
          in:suspendedContext.
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1292
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1293
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1294
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1295
!GenericException methodsFor:'handler actions'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1296
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1297
proceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1298
    "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
  1299
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1300
    self proceedWith:nil.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1301
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1302
    "cg: a strange example: 
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1303
        there are two cought errors here - can you spot them ?
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1304
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1305
     Object errorSignal handle:[:ex|
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1306
         'proceeding' printCR.
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1307
         ex proceed
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1308
     ] do:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1309
         Object errorSignal raiseRequest
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1310
     ].
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1311
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1312
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1313
    "Modified: / 27.3.1997 / 16:44:39 / cg"
4517
8c539600fb63 Implement NoHandlerException etc. as class based exceptions.
Stefan Vogel <sv@exept.de>
parents: 4513
diff changeset
  1314
    "Modified: / 4.8.1999 / 08:42:12 / stefan"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1315
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1316
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1317
proceedWith:value
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1318
    "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
  1319
4507
c15d849b1ddc Remove unused vars.
Stefan Vogel <sv@exept.de>
parents: 4504
diff changeset
  1320
    |con|
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1321
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1322
    proceedable ifFalse:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1323
        "proceed from ProceedError to recover from this error"
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1324
        ProceedError raiseRequestWith:self.
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1325
        proceedable := true.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1326
    ].
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1327
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1328
    thisContext evaluateUnwindActionsUpTo:suspendedContext.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1329
    suspendedContext resumeIgnoringErrors:value.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1330
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1331
    "/ arrive here, if suspended context is not resumable -
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1332
    "/ sigh; resume our raise context ...
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1333
    "/ ... consider this a fallBack kludge, for the case that
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1334
    "/ a raising context is not returnable.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1335
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1336
    "/ find my raise context
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1337
    con := Context findFirstSpecialHandle:false raise:true.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1338
    [con notNil 
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1339
     and:[con receiver ~~ self]] whileTrue:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1340
        con := con findSpecialHandle:false raise:true.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1341
    ].
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1342
    "/ now, have the doCallXXX context at-hand
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1343
    con := con sender.
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1344
    "/ now, have the doRaise context at-hand
4632
522e8accc413 oops - proceed was wrong
Claus Gittinger <cg@exept.de>
parents: 4606
diff changeset
  1345
    con := con sender.
522e8accc413 oops - proceed was wrong
Claus Gittinger <cg@exept.de>
parents: 4606
diff changeset
  1346
    "/ 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
  1347
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1348
    handlerContext := suspendedContext := nil.
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1349
    con resume:value.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
    "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
  1352
    "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
  1353
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1354
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1355
reject
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1356
    "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
  1357
     system will look for another handler"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1358
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1359
    |con|
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1360
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1361
    "/ find my raise context
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1362
    con := Context findFirstSpecialHandle:false raise:true.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1363
    [con notNil 
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1364
     and:[con receiver ~~ self]] whileTrue:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1365
        con := con findSpecialHandle:false raise:true.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1366
    ].
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1367
    "/ 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
  1368
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1369
    rejected := true.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1370
    con unwind:nil.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1371
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1373
     Object errorSignal handle:[:ex |
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1374
        '1' printCR.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1375
        ex reject
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1376
     ] do:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1377
        Object errorSignal handle:[:ex |
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1378
            '2' printCR.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1379
            ex reject
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1380
        ] do:[
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1381
            #() at:1
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1382
        ]
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
     ]
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1384
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1387
resignalAs:anotherException
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1388
    "resignal anotherException, as if it was raised in the first place"
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1389
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1390
    |con|
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1391
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1392
    con := suspendedContext.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1393
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1394
"/    "/ find my raise context
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1395
"/    con := Context findFirstSpecialHandle:false raise:true.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1396
"/    [con notNil 
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1397
"/     and:[con receiver ~~ self]] whileTrue:[
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1398
"/        con := con findSpecialHandle:false raise:true.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1399
"/    ].
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1400
"/    "/ now, have the doCallXXX context at-hand
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1401
"/    con := con sender.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1402
"/    "/ now, have the doRaise context at-hand
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1403
"/    con := con sender.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1404
"/    "/ now, have the raise* context at-hand
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1405
"/    con := con sender.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1406
"/    "/ now, have the raising context at-hand
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1407
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1408
    handlerContext := suspendedContext := nil.
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1409
    con unwindThenDo:[anotherException mayProceed ifTrue:[
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1410
                          anotherException raiseRequest
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1411
                      ] ifFalse:[
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1412
                          anotherException raise
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1413
                      ]
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1414
                     ]
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1415
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1416
    "
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1417
     |rslt n|
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1418
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1419
     Object messageNotUnderstoodSignal handle:[:ex |
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1420
        ex resignalAs:Number divisionByZeroSignal
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1421
     ] do:[
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1422
        rslt := 5 foo
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1423
     ].
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1424
     rslt
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1425
    "
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1426
!
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1427
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
restart
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
    "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
  1430
     in the handler"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1431
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1432
    |con|
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1433
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1434
    con := handlerContext.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1435
    handlerContext := suspendedContext := nil.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1436
    con unwindAndRestart
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1437
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1438
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1439
     |rslt n|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1440
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
     Object errorSignal handle:[:ex |
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1442
        'fixing divisor ...' printCR.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1443
        n := 1.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1444
        ex restart.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1445
     ] do:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1446
        rslt := 5 / n.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1447
     ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1448
     rslt
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
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
restartDo:aBlock
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1453
    "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
  1454
     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
  1455
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1456
    |con|
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1457
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1458
    con := handlerContext.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1459
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1460
"/    handlerContext unwindThenDo:[
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
"/        handlerContext receiver 
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1462
"/            handle:(handlerContext argAt:1)
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
"/            do:aBlock
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
    handlerContext := suspendedContext := nil.
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1466
    con receiver handlerProtectedBlock:aBlock inContext:con.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1467
    con unwindAndRestart
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1468
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1469
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1470
     |sig rslt|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1471
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1472
     sig := Signal new.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1473
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1474
     sig handle:[:ex |
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1475
        ex restartDo:[ rslt := 999 ]
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1476
     ] do:[
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1477
        rslt := 0.
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1478
        sig raise
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1479
     ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1480
     Transcript showCR:rslt
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1481
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1483
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
     |sig rslt|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1485
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1486
     Object errorSignal handle:[:ex |
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1487
        ex restartDo:[ rslt := 999 ]
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1488
     ] do:[
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1489
        rslt := nil foo.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1490
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
     ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1492
     Transcript showCR:rslt
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1493
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1494
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
     |sig rslt|
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
     Object errorSignal handle:[:ex |
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1499
        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
  1500
     ] do:[
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1501
        rslt := nil foo.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1502
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
     Transcript showCR:rslt
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
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1507
    "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
  1508
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1509
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1510
resume
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1511
    "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
  1512
     obsolete (use #proceed), retained for backwards compatibility"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1513
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1514
    self obsoleteMethodWarning:'use #proceed'.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1515
    ^ self proceedWith:nil
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1516
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1517
    "Modified: / 2.3.1998 / 10:51:55 / stefan"
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
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1520
resumeWith:value
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1521
    "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
  1522
     obsolete (use #proceedWith:), retained for backwards compatibility"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1523
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1524
    self obsoleteMethodWarning:'use #proceedWith:'.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1525
    ^ self proceedWith:value
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1526
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1527
    "Modified: / 2.3.1998 / 10:51:48 / stefan"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1528
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1529
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1530
return
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1531
    "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
  1532
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1533
    |con|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1534
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1535
    con := handlerContext.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1536
    handlerContext := suspendedContext := nil.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1537
    con unwind:nil
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1538
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1539
    "Modified: 27.3.1997 / 16:46:39 / cg"
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1540
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1541
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1542
returnDoing:aBlock
4544
2a0e3853d320 #returnDoing works for any exception handler.
Stefan Vogel <sv@exept.de>
parents: 4538
diff changeset
  1543
    "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
  1544
     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
  1545
     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
  1546
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1547
    |con|
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1548
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1549
    con := handlerContext.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1550
    handlerContext := suspendedContext := nil.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1551
    con unwindThenDo:aBlock
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1552
!
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
returnWith:value
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1555
    "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
  1556
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1557
    |con|
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
    con := handlerContext.
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1560
    handlerContext := suspendedContext := nil.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1561
    con unwind:value
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1562
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1563
    "Modified: 27.3.1997 / 16:46:51 / cg"
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
4562
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1566
!GenericException methodsFor:'printing'!
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1567
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1568
description
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1569
    "return the description string of the signal"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1570
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1571
    errorString isNil ifTrue:[
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1572
        ^ signal description
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1573
    ].
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1574
    (errorString startsWith:Character space) ifTrue:[
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1575
        ^ signal description, errorString.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1576
    ].
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1577
    (errorString endsWith:Character space) ifTrue:[
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1578
        ^ errorString, signal description.
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1579
    ].
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1580
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1581
    ^ errorString
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1582
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1583
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1584
      (Error new messageText:'bla') description
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1585
      (Error new messageText:' bla') description
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1586
      (Error new messageText:'bla ') description
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1587
    "
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1588
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1589
    "Modified: / 12.3.1998 / 15:13:28 / stefan"
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1590
! !
2cd0c20d8970 Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4556
diff changeset
  1591
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1592
!GenericException methodsFor:'private'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1593
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1594
doCallAction
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1595
    "call the action proper 
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1596
     - 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
  1597
       ( see implementation of #reject and #proceed)."
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1598
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1599
    <context: #return>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1600
    <exception: #raise>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1601
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
  1602
    "/ thisContext markForRaise. -- same as above pragma
4527
2ddbe34bab87 Make error classes public.
Stefan Vogel <sv@exept.de>
parents: 4521
diff changeset
  1603
    ^ self defaultAction
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1604
!
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1605
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1606
doCallHandler:aHandlerBlock
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1607
    "call the handler proper 
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1608
     - 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
  1609
       ( 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
  1610
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1611
    <context: #return>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1612
    <exception: #raise>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1613
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1614
    |val|
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1615
4491
5041cae5651c use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents: 4488
diff changeset
  1616
    "/ thisContext markForRaise. -- same as above pragma
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1617
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1618
    val := aHandlerBlock value:self.
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
     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
  1621
    "
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1622
    self returnWith:val
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
    "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
  1625
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1626
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1627
doRaise
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1628
    "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
  1629
     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
  1630
     the raising signal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1631
     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
  1632
     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
  1633
     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
  1634
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1635
     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
  1636
     #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
  1637
4488
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1638
    <context: #return>
db914d752859 must mark returned contexts as returnable
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  1639
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1640
    |theContext handler
5197
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1641
     theSignal c ex1 sig1 activeHandlers 
4504
173da3e8b629 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 4498
diff changeset
  1642
     "lastHandler" h r firstHandler searchForHandle|
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1643
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1644
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1645
    "/ is nil a valid originator? If so, we need an extra
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1646
    "/ instanceVariable to record the originator setting.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1647
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1648
    originator isNil ifTrue:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1649
        originator := suspendedContext homeReceiver
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1650
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1651
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1652
    theSignal := signal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1653
    theSignal isSignal ifFalse:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1654
        self halt:'unexpected non-Signal in calling context'.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1655
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1656
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1657
"/ 'search handler for: ' print. theSignal displayString printCR.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1658
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1659
    "/ since the exceptionHandler is evaluated on top of the
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1660
    "/ contextChain, we must skip active handlers before searching.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1661
    "/ otherwise, we get into trouble, when re-raising an exception
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1662
    "/ from within a handler (which would lead to re-executing the
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1663
    "/ same handler)
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1664
    "/ the code below collects active handlers ...
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1665
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1666
    "/ on the fly, look for the first handle - context,
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1667
    "/ and remember it (as firstHandler) to avoid walking the context chain twice
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1668
    "/ in most cases ...
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1669
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1670
    firstHandler := nil.
4504
173da3e8b629 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 4498
diff changeset
  1671
    searchForHandle := true.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1672
4504
173da3e8b629 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 4498
diff changeset
  1673
    c := Context findFirstSpecialHandle:searchForHandle raise:true.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1674
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1675
    [c notNil] whileTrue:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1676
        (c isRaiseContext) ifTrue:[
5197
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1677
            ex1 := c receiver.          "exception, that has been raised before"
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1678
            h := ex1 handlerContext.    "the context of the previous exception handler"
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1679
            h notNil ifTrue:[
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1680
                sig1 := ex1 signal.     "the signal that has been raised before"
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1681
                (sig1 == theSignal      "are we going to raise the same signal again"
4521
946e1a02b158 emove unused classvar.
Stefan Vogel <sv@exept.de>
parents: 4519
diff changeset
  1682
5197
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1683
                "/ mhmh - if not ==, the raised signal there is not ours, 
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1684
                "/ but the handler could still be for a signalSet, parentSig
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1685
                "/ or other thingy which accepts our signal.
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1686
                "/ If we omit that check, a signalSet-handler gets invoked
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1687
                "/ again by an exception occuring inside its handler.
4521
946e1a02b158 emove unused classvar.
Stefan Vogel <sv@exept.de>
parents: 4519
diff changeset
  1688
5197
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1689
                "/ to avoid overhead, only do it if the
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1690
                "/ handlers receiver is not of the signals class...
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1691
                "/ ...i.e. knowing that most are r handle:do: contexts,
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1692
                "/ where the receiver is the handling signal.
4521
946e1a02b158 emove unused classvar.
Stefan Vogel <sv@exept.de>
parents: 4519
diff changeset
  1693
5197
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1694
                "is the signal that has been raised different 
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1695
                 from the signal that has been handled?"
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1696
                or:[(h receiver handlingExceptionInContext:h) ~~ sig1
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1697
                    and:[ex1 handlingException accepts:theSignal]]) ifTrue:[
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1698
                    "...and will the previous handler accept the signal 
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1699
                     we are going to raise?"
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1700
                    activeHandlers isNil ifTrue:[
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1701
                        activeHandlers := OrderedCollection new
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1702
                    ].
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1703
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1704
                    activeHandlers add:h.
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1705
                    "/ lastHandler := h.
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1706
                    c := h.
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1707
                ]
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1708
            ]
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1709
        ] ifFalse:[
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1710
            "/ must be a handle context ...
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1711
            firstHandler := c.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1712
            searchForHandle := false.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1713
        ].
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1714
        c := c findSpecialHandle:searchForHandle raise:true.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1715
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1716
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1717
    h := nil.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1718
    c := nil.
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1719
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1720
    "/ now, start searching for a handler,
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1721
    "/ start search above the last active handler.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1722
    "/ Or start with the first handle context, if one
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1723
    "/ was found as a side effect of the previous handler search.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1724
    "/ If nil, then there is no handler and we can directly proceed
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1725
    "/ to the unhandled code below.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1726
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1727
"/    lastHandler notNil ifTrue:[
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1728
"/        theContext := lastHandler.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1729
"/        theContext := lastHandler findNextHandleContext
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1730
"/    ] ifFalse:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1731
        theContext := firstHandler.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1732
"/    ].
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1733
    firstHandler := nil.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1734
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1735
    [theContext notNil] whileTrue:[
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1736
        "/
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1737
        "/  ask the Signal instance/Exception class for the handler.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1738
        "/  nil is returned, if the signal is not accepted
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1739
        "/
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1740
        r := theContext receiver.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1741
        (r notNil and:[(handler := r handlerForSignal:signal 
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1742
                                     context:theContext 
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1743
                                     originator:originator) notNil]
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1744
        ) ifTrue:[
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1745
            (activeHandlers notNil
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1746
             and:[activeHandlers includesIdentical:theContext]) ifTrue:[
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1747
"/                'skip activeHandler: ' print. theContext displayString printCR.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1748
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1749
            ] ifFalse:[
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1750
                "call the handler"
4521
946e1a02b158 emove unused classvar.
Stefan Vogel <sv@exept.de>
parents: 4519
diff changeset
  1751
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1752
                handlerContext := theContext.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1753
                "/ remember the handling signal, sigSet, or exception
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1754
                "/ for the #accepts: check above
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1755
                handlingException := r handlingExceptionInContext:theContext.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1756
                theContext := nil.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1757
                self doCallHandler:handler.
4521
946e1a02b158 emove unused classvar.
Stefan Vogel <sv@exept.de>
parents: 4519
diff changeset
  1758
4548
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1759
                "/ if the handler rejects, we arrive here
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1760
                "/ continue search for another handler
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1761
                theContext := handlerContext.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1762
                handlerContext := nil.
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1763
            ].
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1764
        ].
8349abc6b796 Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents: 4544
diff changeset
  1765
        theContext := theContext findSpecialHandle:true raise:false.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1766
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1767
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1768
    "/ help GC a bit, by clearing things we no longer need
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1769
    "/ (especially useful for contexts ...)
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1770
    activeHandlers := handler := ex1 := firstHandler := nil.
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1771
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
     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
  1774
     or every handler rejected.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1775
    "
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1776
    ^ self doCallAction
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1777
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1778
    "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
  1779
    "Modified: / 9.11.1997 / 14:48:44 / cg"
4504
173da3e8b629 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 4498
diff changeset
  1780
    "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
  1781
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1782
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1783
!GenericException methodsFor:'raising'!
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
raise
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1786
    "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
  1787
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1788
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1789
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1790
    suspendedContext isNil ifTrue:[
4538
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
  1791
        suspendedContext := thisContext sender
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1792
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1793
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1794
    proceedable := false.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1795
    ^ self doRaise
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1796
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1797
    "Modified: / 12.5.1996 / 15:09:47 / cg"
4507
c15d849b1ddc Remove unused vars.
Stefan Vogel <sv@exept.de>
parents: 4504
diff changeset
  1798
    "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
  1799
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1800
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1801
raiseRequest
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1802
    "actually raise a proceedable exception."
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1803
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1804
    <context: #return>
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1805
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1806
    suspendedContext isNil ifTrue:[
4538
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
  1807
        suspendedContext := thisContext sender
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1808
    ].
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1809
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1810
    self mayProceed ifFalse:[
4538
25c5124b8c79 minidebugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
  1811
        "/ proceeding from wrongProceedabilitySignal grants the raiseRequest
4556
b654bb087103 new proceed code.
Claus Gittinger <cg@exept.de>
parents: 4554
diff changeset
  1812
        WrongProceedabilityError raiseRequestWith:signal
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1813
    ].
4484
9476c82921d0 eliminated proceedBlock and rejectBlock;
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  1814
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1815
    proceedable := true.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1816
    ^ self doRaise
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1817
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1818
    "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
  1819
    "Modified: / 4.8.1999 / 08:05:12 / stefan"
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1820
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1821
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1822
!GenericException methodsFor:'setup'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1823
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1824
signal:aSignal originator:origin
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1825
    "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
  1826
     - 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
  1827
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1828
    signal := aSignal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1829
    originator := origin.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1830
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1831
    "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
  1832
!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1833
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1834
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
  1835
    "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
  1836
     - 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
  1837
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1838
    signal := aSignal.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1839
    parameter := aParameter.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1840
    errorString := aString.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1841
    suspendedContext := sContext.
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1842
    originator := origin.
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
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1845
!GenericException class methodsFor:'documentation'!
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1846
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1847
version
5197
14331ce13d51 Fix detection of active handlers (change for class based exceptions)
Stefan Vogel <sv@exept.de>
parents: 5061
diff changeset
  1848
    ^ '$Header: /cvs/stx/stx/libbasic/GenericException.st,v 1.33 2000-01-21 19:59:45 stefan Exp $'
4481
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1849
! !
f3f7e1af7489 added GenericException in-between, to allow for some exceptions
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1850
GenericException initialize!