NoHandlerError.st
author Stefan Vogel <sv@exept.de>
Wed, 01 Sep 2004 16:45:23 +0200
changeset 8508 68cd95545196
parent 8399 2c311d438f2c
child 8678 41d332006a49
permissions -rw-r--r--
Allow to proceed with any stream from an #openError handler
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4554
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
     1
"
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
     2
 COPYRIGHT (c) 1999 by eXept Software AG
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
     3
              All Rights Reserved
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
     4
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
     5
 This software is furnished under a license and may be used
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
     6
 only in accordance with the terms of that license and with the
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
     8
 be provided or otherwise made available to, or used by, any
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
     9
 other person.  No title to or ownership of the software is
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    10
 hereby transferred.
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    11
"
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    12
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    13
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    14
6210
d7039e2ae776 caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents: 5295
diff changeset
    15
"{ Package: 'stx:libbasic' }"
d7039e2ae776 caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents: 5295
diff changeset
    16
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    17
GenericException subclass:#NoHandlerError
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    18
	instanceVariableNames:''
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    19
	classVariableNames:'EmergencyHandler'
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
6210
d7039e2ae776 caetgory change and documentation added
Claus Gittinger <cg@exept.de>
parents: 5295
diff changeset
    21
	category:'Kernel-Exceptions-Errors'
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    22
!
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    23
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    24
!NoHandlerError class methodsFor:'documentation'!
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    25
4554
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    26
copyright
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    27
"
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    28
 COPYRIGHT (c) 1999 by eXept Software AG
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    29
              All Rights Reserved
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    30
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    31
 This software is furnished under a license and may be used
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    32
 only in accordance with the terms of that license and with the
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    34
 be provided or otherwise made available to, or used by, any
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    35
 other person.  No title to or ownership of the software is
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    36
 hereby transferred.
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    37
"
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    38
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    39
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    40
!
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    41
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    42
documentation
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    43
"
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    44
    NoHandlerError is raised, if there is no exception handler
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    45
    or default action for an exception.
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    46
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    47
    The parameter is the unhandled exception.
4554
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    48
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    49
    [Class variables:]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    50
        EmergencyHandler <Block>    this block is evaluated, if no handler was defined
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    51
                                    for a signal (i.e. this one is responsible for the
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    52
                                    unhandled exception debugger).
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    53
                                    Having this being a block allows to globally catch
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    54
                                    these errors - even when no enclosing handler-scope
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    55
                                    around the erronous code exists.
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    56
                                    (as the catch/through does).
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    57
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    58
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    59
    [see also:]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    60
        GenericException 
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    61
        (``Exception handling and signals'': programming/exceptions.html)
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    62
"
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    63
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    64
4554
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    65
!
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    66
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    67
examples
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    68
"
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    69
    The emergencyHandler stuff is very useful, to prevent endUser applications
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    70
    from entering the debugger.
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    71
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    72
    Some commonly used (useful) emergency handlers are provided in the
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    73
    'useful handlers' section; try them to learn more
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    74
    (especially, the mailingHandler is fun).
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    75
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    76
    Of course, these are only examples - you may define your own handler
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    77
    block and pass it to the #emergencyHandler: method.
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    78
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    79
    BTW: the Launchers 'source & debugger' settings menu allows you
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    80
         to install either a default or the notifying handler.
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    81
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    82
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    83
    A handler which shows a box, then aborts - (no more debuggers):
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    84
                                                                [exBegin]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    85
        NoHandlerError emergencyHandler:(NoHandlerError abortingEmergencyHandler)
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    86
                                                                [exEnd]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    87
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    88
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    89
    A handler which aborts - (no box, no debugger):
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    90
                                                                [exBegin]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    91
        NoHandlerError emergencyHandler:[:ex | AbortSignal raise]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    92
                                                                [exEnd]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    93
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    94
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    95
    try some exception (for demonstration, in some other process):
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    96
                                                                [exBegin]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    97
        [
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    98
            #(1 2 3) at:4
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
    99
        ] fork.
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   100
                                                                [exEnd]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   101
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   102
    cleanup (switch back to the regular handler, which enters the debugger):
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   103
                                                                [exBegin]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   104
        NoHandlerError emergencyHandler:nil
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   105
                                                                [exEnd]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   106
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   107
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   108
    A handler which shows a warnBox and asks for debugging:
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   109
                                                                [exBegin]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   110
        NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandler)
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   111
                                                                [exEnd]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   112
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   113
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   114
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   115
    A handler which dumps information to a file (watch the file 'errorTrace.stx'):
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   116
                                                                [exBegin]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   117
        NoHandlerError emergencyHandler:(NoHandlerError dumpingEmergencyHandler)
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   118
                                                                [exEnd]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   119
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   120
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   121
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   122
    A handler which sends you mail:
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   123
                                                                [exBegin]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   124
        NoHandlerError emergencyHandler:(NoHandlerError mailingEmergencyHandler)
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   125
                                                                [exEnd]
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   126
"
db264efac2c0 Add copyright.
Stefan Vogel <sv@exept.de>
parents: 4539
diff changeset
   127
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   128
! !
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   129
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   130
!NoHandlerError class methodsFor:'initialization'!
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   131
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   132
initialize
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   133
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   134
    NotifierString := 'unhandled exception'.
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   135
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   136
    "
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   137
     self initialize
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   138
    "
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   139
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   140
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   141
! !
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   142
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   143
!NoHandlerError class methodsFor:'emergency handlers'!
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   144
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   145
emergencyHandler
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   146
    "return the handler used for unhandled exceptions.
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   147
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   148
     If no EmergencyHandler has been set, a handler which enters the 
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   149
     debugger is returned.
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   150
     The debugger is opened by asking the signal for a debug action,
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   151
     this allows to provide other debuggers in specialized (subclass-instances)
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   152
     of Signal (if that is ever needed)"
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   153
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   154
    "
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   155
     set it up, when called the first time
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   156
    "
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   157
    EmergencyHandler isNil ifTrue:[
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   158
        EmergencyHandler := [:ex |
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   159
            "
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   160
             sending it to the signal allows per-signal specific
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   161
             debuggers to be implemented in the future
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   162
             (for example, segv in primitive code could show things 
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   163
              on the C-level ..)
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   164
            "
4586
22c84f7f9b85 return nil from raise if proceeded in the debugger
Claus Gittinger <cg@exept.de>
parents: 4561
diff changeset
   165
            (ex signal) openDebuggerOnException:ex.
22c84f7f9b85 return nil from raise if proceeded in the debugger
Claus Gittinger <cg@exept.de>
parents: 4561
diff changeset
   166
            "/ if we arrive here, the debugger proceeded.
8399
2c311d438f2c #emergencyHandler - allow the debugger to proceed with a value
Stefan Vogel <sv@exept.de>
parents: 7586
diff changeset
   167
            "/ the value returned by #openDebuggerOnException: is the exceptions value ...
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   168
        ]
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   169
    ].
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   170
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   171
    ^ EmergencyHandler
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   172
!
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   173
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   174
emergencyHandler:aOneArgBlock
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   175
    "set the handler used for unhandled exceptions.
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   176
     The default (a nil-handler) leads to a debugger to be shown."
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   177
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   178
    EmergencyHandler := aOneArgBlock
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   179
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   180
    "ST-80 behavior of first showing a notifier:
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   181
     (I prefer to get right into the debugger, though)
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   182
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   183
     Exception
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   184
        emergencyHandler:
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   185
            [:ex | self errorNotify:ex errorString ]
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   186
    "
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   187
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   188
    "ST-X behavior of going right into the debugger:
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   189
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   190
     Exception
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   191
        emergencyHandler:nil
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   192
    "
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   193
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   194
    "automatically aborting current operation, on error:
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   195
     (may be useful for end-user apps; make certain, 
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   196
      you have abortSignal handlers at appropriate places)
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   197
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   198
     Exception
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   199
        emergencyHandler:
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   200
            [:ex | Object abortSignal raise. ex return. ]
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   201
    "
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   202
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   203
    "finally, traditional language system behavior; dump core ;-)
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   204
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   205
     Exception
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   206
        emergencyHandler:
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   207
            [:ex | Smalltalk exitWithCoreDump. ]
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   208
    "
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   209
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   210
    "Modified: 15.1.1997 / 20:49:06 / cg"
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   211
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   212
! !
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   213
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   214
!NoHandlerError methodsFor:'default actions'!
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   215
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   216
defaultAction
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   217
    "This action is performed, if nobody handles the NoHandlerError.
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   218
     Look for either a per-process emergencyHandlerBlock 
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   219
     or the global emergencyHandler (from Exception) ..."
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   220
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   221
    |block|
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   222
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   223
    Processor notNil ifTrue:[ 
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   224
        "care for signal during startup (Processor not yet created)"
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   225
        block := Processor activeProcess emergencySignalHandler.
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   226
    ].
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   227
    block isNil ifTrue:[
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   228
        block := self class emergencyHandler.
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   229
        block isNil ifTrue:[
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   230
            "care for error during startup (Exception not yet initialized)"
4539
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   231
            ^ MiniDebugger 
5295
f144309dab04 #errorString --> #description
Stefan Vogel <sv@exept.de>
parents: 4937
diff changeset
   232
                enterWithMessage:self description 
4539
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   233
                mayProceed:self mayProceed
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   234
        ].
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   235
    ].
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   236
4586
22c84f7f9b85 return nil from raise if proceeded in the debugger
Claus Gittinger <cg@exept.de>
parents: 4561
diff changeset
   237
    ^ block value:self
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   238
4561
c82f8c848d4c Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4554
diff changeset
   239
!
c82f8c848d4c Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4554
diff changeset
   240
c82f8c848d4c Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4554
diff changeset
   241
noHandler
c82f8c848d4c Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4554
diff changeset
   242
    "redefined to avoid recursive invocations"
c82f8c848d4c Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4554
diff changeset
   243
c82f8c848d4c Add #description, #creator
Stefan Vogel <sv@exept.de>
parents: 4554
diff changeset
   244
    ^ self
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   245
! !
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   246
4539
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   247
!NoHandlerError methodsFor:'queries'!
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   248
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   249
mayProceed
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   250
    "return true, if the exception handler is allowed to proceed
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   251
     the execution where the exception occured."
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   252
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   253
    parameter isNil ifTrue:[^ true].
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   254
    ^ parameter mayProceed
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   255
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   256
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   257
! !
7064506e8285 debugger entry protocol changed;
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   258
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   259
!NoHandlerError class methodsFor:'documentation'!
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   260
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   261
version
8399
2c311d438f2c #emergencyHandler - allow the debugger to proceed with a value
Stefan Vogel <sv@exept.de>
parents: 7586
diff changeset
   262
    ^ '$Header: /cvs/stx/stx/libbasic/NoHandlerError.st,v 1.10 2004-06-11 18:23:44 stefan Exp $'
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   263
! !
7586
63e4900c8931 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
   264
4528
5ef0de6abb50 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   265
NoHandlerError initialize!