Exception.st
author claus
Fri, 16 Jul 1993 11:39:45 +0200
changeset 1 a27a279701f8
child 3 24d81bf47225
permissions -rw-r--r--
Initial revision

"
 COPYRIGHT (c) 1993 by Claus Gittinger
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

Object subclass:#Exception
         instanceVariableNames:'signal parameter suspendedContext handlerContext
                                resumeBlock rejectBlock'
         classVariableNames:''
         poolDictionaries:''
         category:'Kernel-Exceptions'
!

Exception comment:'

COPYRIGHT (c) 1993 by Claus Gittinger
              All Rights Reserved

Instances of Exception are passed to a Signal handling block as argument.
The handler block may perform various actions by sending corresponding messages
to the exception handler. The following actions are possible:

        reject          - dont handle this signal;
                          another handler will be searched for, 
                          upper in the calling hierarchy

        proceed         - continue after the Signal>>raise, returning nil as value
        proceedWith:val - same, but return val from Signal>>raise

        return          - return from the Signal>>handle:do:, returning nil as value
        return:val      - same, but return val from Signal>>handle:do:

        restart         - restart the Signal>>handle:do:, after repairing

Via the Exception object, the handler can also query the state of execution,
where the Signal was raised.
'!

!Exception methodsFor:'accessing'!

signal
    "return the signal, that caused the exception"

    ^ signal
!

parameter:aParameter
    parameter := aParameter
!

parameter
    ^ parameter
!

suspendedContext
! !

!Exception methodsFor:'setup'!

signal:aSignal
    "this is meant to be sent by Signal only"

    signal := aSignal
!

handlerContext:aContext
    "this is meant to be sent by Signal only"

    handlerContext := aContext
!

rejectBlock:aBlock
    "this is meant to be sent by Signal only"

    rejectBlock := aBlock
!

resumeBlock:aBlock
    "this is meant to be sent by Signal only"

    resumeBlock := aBlock
! !

!Exception methodsFor:'handler actions'!

reject
    "handler decided not to handle this signal -
     system will look for another handler"

    rejectBlock value
!

resume
    "Continue after the raise - the raise returns nil"

    resumeBlock value:nil
!

resumeWith:value
    "Continue after the raise - the raise returns value"

    resumeBlock value:value
!

proceed
    "Continue after the raise - the raise returns nil"

    resumeBlock value:nil
!

proceedWith:value
    "Continue after the raise - the raise returns value"

    resumeBlock value:value
!

return
    "Continue after the handle:do: - the handle:do: returns nil"

    handlerContext resume
!

returnWith:value
    "Continue after the handle:do: - the handle:do: returns value"

    handlerContext resume:value
!

restart
    "restart the handle:do: - usually after some repair work is done
     in handler"

    handlerContext restart
! !