eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'NoHandlerError':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: NoHandlerError


Inheritance:

   Object
   |
   +--GenericException
      |
      +--NoHandlerError

Package:
stx:libbasic
Category:
Kernel-Exceptions-Errors
Version:
rev: 1.28 date: 2017/06/20 10:18:52
user: cg
file: NoHandlerError.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


NoHandlerError is raised, if there is no exception handler
or default action for an exception.

The parameter is the unhandled exception.

[Class variables:]
    EmergencyHandler <Block>    this block is evaluated, if no handler was defined
                                for a signal (i.e. this one is responsible for the
                                unhandled exception debugger).
                                Having this being a block allows to globally catch
                                these errors - even when no enclosing handler-scope
                                around the erroneous code exists.
                                (as the catch/through does).


Related information:

    GenericException
    [``Exception handling and signals'']

Class protocol:

accessing emergencyHandler
o  emergencyHandler
return the handler used for unhandled exceptions.

If no EmergencyHandler has been set, a handler which enters the
debugger is returned.
The debugger is opened by asking the signal for a debug action,
this allows to provide other debuggers in specialized (subclass-instances)
of Signal (if that is ever needed)
usage example(s):
     NoHandlerError emergencyHandler:[:ex | Transcript showCR:ex description.
					    ex signal openDebuggerOnException:ex].

o  emergencyHandler: aOneArgBlock
set the handler used for unhandled exceptions.
The default (a nil-handler) leads to a debugger to be shown.
usage example(s):
ST-80 behavior of first showing a notifier:
     (I prefer to get right into the debugger, though)

     NoHandlerError
	emergencyHandler:
	    [:ex | self errorNotify:ex description ]
usage example(s):
ST-X behavior of going right into the debugger:

     NoHandlerError
	emergencyHandler:nil

initialization
o  initialize
self initialize

useful emergency handlers
o  abortingEmergencyHandler
return a block (usable as an emergency handler),
which aborts after showing a warnBox.
This is useful for endUser applications.
usage example(s):
test with (try a few halts or CTRL-C's):
     NoHandlerError emergencyHandler:(NoHandlerError abortingEmergencyHandler)

o  dumpingEmergencyHandler
return a block (usable as an emergency handler),
which dumps the stackBacktrace to a trace file and
aborts after showing a warnBox.
This is useful, for endUser application, which are still being
debugged (i.e. the programmers may have a look at the traceFile
from time to time).

Notice:
The code below is just an example; you may want to change the
name of the error-file in your application
(but please: copy the code; do not modify here)
usage example(s):
test with (try a few halts or CTRL-C's):
     NoHandlerError emergencyHandler:(NoHandlerError dumpingEmergencyHandler)

o  mailingEmergencyHandler
return a block (usable as an emergency handler),
which shows a warnBox and optionally mails a stackBacktrace to a maintainer.
This is useful, for endUser application, which are still being
debugged (i.e. the programmers may have a look at the errors).

Notice: the stuff here is a demonstration only; it should be modified
for your particular environment ...
... but please: copy the code and modify there;
leave the stuff below as it is.
usage example(s):
test with (try a few halts or CTRL-C's):
     NoHandlerError emergencyHandler:(NoHandlerError mailingEmergencyHandler)

o  notifyingEmergencyHandler
return a block (usable as an emergency handler for exceptions),
which does errorNotification before going into the debugger.
Halts and breakpoints go directly into the debugger (without asking)

o  notifyingEmergencyHandlerForUserProcesses
return a block (usable as an emergency handler for exceptions),
which does errorNotification before going into the debugger,
but only for exceptions occurring in user processes;
systemProcesses are not debugged.
Halts and breakpoints go directly into the debugger (without asking)
usage example(s):
test with:
     NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandlerForUserProcesses)
     Object bla.


Instance protocol:

accessing
o  exception
the original exception, which was responsible for this.
ANSI compatibility

o  originalSignal
return the signal/exception which was originally raised.
For noHandler, that is my unhandled signal; for others, that's the exception itself.

o  unhandledException
the original exception, which was responsible for this.
Obsolete: use #exception for ANSI comatibility.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

default actions
o  defaultAction
This action is performed, if nobody handles the NoHandlerError.
Look for either a per-process emergencyHandlerBlock
or the global emergencyHandler ...

o  defaultResumeValue
redefined to ask the underlying unhandled exception for its default resume value

o  noHandler
redefined to avoid recursive invocations

printing & storing
o  descriptionForDebugger
return the description string of the signal which is used in the
debugger title area

queries
o  mayProceed
return true, if the exception handler is allowed to proceed
the execution where the exception occurred.


Examples:


The emergencyHandler stuff is very useful, to prevent endUser applications from entering the debugger. Some commonly used (useful) emergency handlers are provided in the 'useful handlers' section; try them to learn more (especially, the mailingHandler is fun). Of course, these are only examples - you may define your own handler block and pass it to the #emergencyHandler: method. BTW: the Launchers 'source & debugger' settings menu allows you to install either a default or the notifying handler. A handler which shows a box, then aborts - (no more debuggers):
    NoHandlerError emergencyHandler:(NoHandlerError abortingEmergencyHandler)
A handler which aborts - (no box, no debugger):
    NoHandlerError emergencyHandler:[:ex | AbortSignal raise]
try some exception (for demonstration, in some other process):
    [
        #(1 2 3) at:4
    ] fork.
cleanup (switch back to the regular handler, which enters the debugger):
    NoHandlerError emergencyHandler:nil
A handler which shows a warnBox and asks for debugging:
    NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandler)
A handler which dumps information to a file (watch the file 'errorTrace.stx'):
    NoHandlerError emergencyHandler:(NoHandlerError dumpingEmergencyHandler)
A handler which sends you mail:
    NoHandlerError emergencyHandler:(NoHandlerError mailingEmergencyHandler)


ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Wed, 19 Sep 2018 11:04:06 GMT