ExcHandling extensions and a question
Stephen Pope
stp at create.ucsb.edu
Tue Mar 23 17:50:38 UTC 1999
Below are a few (hopefully useful) extensions to Craig Latta's excellent exception handling code.
I have one question: I can't figure out how to make an exception event proceedable. Even if you
create a proceedable situation, it looks as if exceptions that are cases of it are non-proceedable.
Am I missing something?
stp
----------------------------------
!GraphNode methodsFor: 'printing' stamp: 'stp 03/22/1999 10:16'!
printHierarchyOn: aStream level: level
"Print out the receiver and all of its descendents, nicely indented."
"(Situation named: #root) printHierarchyOn: Transcript level: 0"
level timesRepeat: [Transcript tab].
Transcript show: self name; cr.
self hasChildren
ifTrue: [children do: [ :des | des printHierarchyOn: aStream level: (level + 1)]]! !
!GraphNode methodsFor: 'accessing' stamp: 'stp 03/22/1999 10:13'!
children
^children! !
!Situation class methodsFor: 'utilities' stamp: 'stp 03/22/1999 10:16'!
readme
"Print out the hierarchy of exceptions."
"(Situation named: #root) printHierarchyOn: Transcript level: 0"
! !
!Situation class methodsFor: 'initialization' stamp: 'stp 03/21/1999 18:28'!
addSituations
"Add situations to the system."
Smalltalk
addSituationNamed: #exceptionHandlingError
asSpecializationOfSituationNamed: #root
withDescription: 'An error in exception handling has occurred.'
andProceedability: false;
addSituationNamed: #unsupportedSituation
asSpecializationOfSituationNamed: #exceptionHandlingError
withDescription: 'The system has encountered an unsupported situation.'
andProceedability: true;
addSituationNamed: #proceedabilityConflict
asSpecializationOfSituationNamed: #exceptionHandlingError
withDescription: 'There was a proceedability conflict in handling an exception.'
andProceedability: false;
addSituationNamed: #noHandler
asSpecializationOfSituationNamed: #exceptionHandlingError
withDescription: 'There is no handler for this exception.'
andProceedability: false;
addSituationNamed: #error
asSpecializationOfSituationNamed: #root
withDescription: 'An error has occurred.'
andProceedability: false! !
!BlockContext methodsFor: 'evaluating-exception handling' stamp: 'stp 03/23/1999 06:32'!
on: situationName handle: handlerBlock
"Evaluate myself with no parameters. If the situation named situationName occurs during evaluation, pass control to handlerBlock. That block should take one parameter: the Exception generated by the situation. The passage of control is accomplished via that Exception manipulating the Context stack. This is a facility for 'synchronous exception handling'. See the comment for Situation for details."
^self valueHandlingAnyOf: (Array with: situationName) with: handlerBlock! !
--
stp
Stephen Travis Pope
stp at create.ucsb.edu http://www.create.ucsb.edu/~stp/
More information about the Squeak-dev
mailing list
|