# HG changeset patch # User Claus Gittinger # Date 940864255 -7200 # Node ID 7e723f1daca7e45ee5aa8c95cbe7968c55433484 # Parent bc943fef0d96352eb2b5b9d755e3ce222f758596 *** empty log message *** diff -r bc943fef0d96 -r 7e723f1daca7 NoHandlerError.st --- a/NoHandlerError.st Mon Oct 25 17:10:46 1999 +0200 +++ b/NoHandlerError.st Mon Oct 25 17:10:55 1999 +0200 @@ -212,219 +212,6 @@ ! ! -!NoHandlerError class methodsFor:'useful handlers'! - -abortingEmergencyHandler - "return a block (usable as an emergency handler), - which aborts after showing a warnBox. - This is useful for endUser applications" - - ^ [:ex | self warn:'Error: ' , ex errorString. - AbortSignal raise - ] - - "test with (try a few halts or CTRL-C's): - NoHandlerError emergencyHandler:(NoHandlerError abortingEmergencyHandler) - " - - "back with: - NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandler) - NoHandlerError emergencyHandler:nil - " - - "Created: 15.1.1997 / 20:13:06 / cg" - "Modified: 15.1.1997 / 20:15:02 / cg" -! - -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)" - - ^ [:ex | - |str printedException| - - ex signal == NoHandlerError ifTrue:[ - printedException := ex parameter. - ] ifFalse:[ - printedException := ex - ]. - - "/ user interruption is handled specially: - "/ allow user to choose between proceeding or aborting - "/ but never dump that information to the file. - - printedException signal == Object userInterruptSignal ifTrue:[ - (self confirm:'abort current action ?') ifTrue:[ - AbortSignal raise - ]. - ex proceedWith:nil - ]. - - "/ - "/ dump it to 'errorTrace.stx' - "/ - str := 'errorTrace.stx' asFilename appendingWriteStream. - - str nextPutLine:('******************************* ' - , AbsoluteTime now printString - , ' *******************************'). - str cr. - - str nextPutLine:('** Error: ' , printedException errorString). - str nextPutLine:('** Signal: ' , printedException signal printString). - str nextPutLine:('** Parameter: ' , printedException parameter printString). - str nextPutLine:('** Process: ' , Processor activeProcess printString). - str nextPutLine:('** Backtrace:'). - str cr. - - printedException suspendedContext fullPrintAllOn:str. - str cr. - str cr. - str close. - - "/ send a line to stdErr - - ('[warning]: ignored error: ' , printedException errorString) errorPrintCR. - ('[warning]: error information appended to ''errorTrace.stx''') errorPrintCR. - - AbortSignal raise - ] - - "test with (try a few halts or CTRL-C's): - NoHandlerError emergencyHandler:(NoHandlerError dumpingEmergencyHandler) - " - - "back with: - NoHandlerError emergencyHandler:(NoHandlerError notifyingEmergencyHandler) - NoHandlerError emergencyHandler:nil - " - - "Created: / 15.1.1997 / 20:14:52 / cg" - "Modified: / 24.1.1997 / 20:36:21 / cg" - "Modified: / 4.8.1999 / 08:11:20 / stefan" -! - -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." - - ^ [:ex | - |str printedException doMail emergencyMailReceiver pipe| - - ex signal == NoHandlerError ifTrue:[ - printedException := ex parameter. - ] ifFalse:[ - printedException := ex - ]. - - "/ user interruption is handled specially: - "/ allow user to choose between proceeding or aborting - "/ but never dump that information to the file. - - printedException signal == Object userInterruptSignal ifTrue:[ - (self confirm:'abort current action ?') ifTrue:[ - AbortSignal raise - ]. - ex proceedWith:nil - ]. - - "/ somehow get the name of the guy to receive the mail - "/ you have to implement that yourself. - - "/ emergencyMailReceiver := OneOfYourClass getEmergencyMailReceiver. - emergencyMailReceiver := OperatingSystem getLoginName. - - emergencyMailReceiver isNil ifTrue:[ - self warn:(printedException errorString - , '\\No mailing to service people possible.') withCRs. - doMail := false. - ] ifFalse:[ - doMail := self confirm:(printedException errorString - , '\\Mail error information to the service people (' - , emergencyMailReceiver , ') ?') withCRs - ]. - doMail ifTrue:[ - str := '' writeStream. - - str nextPutLine:('Error notification from ' - , OperatingSystem getLoginName - , '@' - , OperatingSystem getHostName). - str cr. - - str nextPutLine:('Time: ' , AbsoluteTime now printString). - str nextPutLine:('Error: ', printedException errorString). - str nextPutLine:('Signal: ', printedException signal printString). - str nextPutLine:('Parameter: ', printedException parameter printString). - str nextPutLine:('Process: ', Processor activeProcess printString). - str nextPutLine:'Backtrace:'. - str cr. - - printedException suspendedContext fullPrintAllOn:str. - str cr;cr. - - str close. - - pipe := PipeStream - writingTo:'mail ', emergencyMailReceiver. - pipe notNil ifTrue:[ - pipe nextPutLine:'Subject: automatic error report'. - pipe nextPutAll:str contents. - pipe cr. - pipe close. - ] - ]. - - AbortSignal raise - ] - - "test with (try a few halts or CTRL-C's): - NoHandlerError emergencyHandler:(Exception mailingEmergencyHandler) - " - - "back with: - NoHandlerError emergencyHandler:(Exception notifyingEmergencyHandler) - NoHandlerError emergencyHandler:nil - " - - "Created: / 15.1.1997 / 20:14:52 / cg" - "Modified: / 15.1.1997 / 21:10:28 / cg" - "Modified: / 4.8.1999 / 08:11:26 / stefan" -! - -notifyingEmergencyHandler - "return a block (usable as an emergency handler for exceptions), - which does errorNotification before going into the debugger." - - ^ [:ex | nil errorNotify:ex errorString from:ex suspendedContext ] - - "test with (try a few halts or CTRL-C's): - Exception emergencyHandler:(Exception notifyingEmergencyHandler) - " - - "back with: - NoHandlerError emergencyHandler:nil - " - - "Modified: 15.1.1997 / 20:15:12 / cg" -! ! - !NoHandlerError methodsFor:'default actions'! defaultAction @@ -473,6 +260,6 @@ !NoHandlerError class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/NoHandlerError.st,v 1.5 1999-08-10 18:41:49 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/NoHandlerError.st,v 1.6 1999-10-25 15:10:55 cg Exp $' ! ! NoHandlerError initialize!