fixed processor_return_to

This commit is contained in:
hyunghwan.chung
2016-04-30 05:56:35 +00:00
parent 94717d197a
commit 77990a5172
3 changed files with 32 additions and 12 deletions

View File

@ -302,6 +302,12 @@ thisContext isHandlerContext dump.
self signal.
}
#method pass
{
## pass the exception to the outer context
## TODO:
}
#method isHandled
{
^self handlerContext notNil
@ -309,7 +315,7 @@ thisContext isHandlerContext dump.
#method handle
{
self return: (self.handlerContext handlerBlock value: self)
Processor return: (self.handlerContext handlerBlock value: self) to: (self.handlerContext sender)
}
#method notHandled
@ -322,28 +328,23 @@ Processor activeProcess terminate.
#method handlerContext
{
(self.handlerContext notNil) ifTrue: [ ^self.handlerContext ].
^self handlerContextStartingFrom: self.signalContext sender.
self.handlerContext := self findHandlerContextStartingFrom: self.signalContext.
^self.handlerContext.
}
#method handlerContextStartingFrom: aContext
#method findHandlerContextStartingFrom: aContext
{
## Find exception handling context starting from a given context
| ctx |
ctx := aContext.
[ ctx notNil ]
whileTrue: [
(ctx handles: self) ifTrue: [ ^self.handlerContext := ctx ].
(ctx handles: self) ifTrue: [ ^ ctx ].
ctx := ctx sender
].
^nil
}
#method return: anObject
{
Processor return: anObject to: (self.handlerContext parent)
}
}
#class NoSuchMessageException(Exception)

View File

@ -37,8 +37,22 @@
#class MyObject(TestObject)
{
#method(#class) main2
{
| k |
k := ['this is test-011' dump. Exception signal. 8888 dump. ]
on: Exception do: [ :ex | 'Exception occurred' dump. ex dump. 'Getting back to' dump. 80. ex pass ].
k dump.
'END OF test-011' dump.
}
#method(#class) main
{
['this is test-011' dump. Exception signal. ] on: Exception do: [ :ex | 'Exception occurred' dump ].
'>>>>> BEGINNING OF MAIN' dump.
[ self main2 ] on: Exception do: [ :ex | 'EXCEPTION CAUGHT IN MAIN....' dump ].
'>>>>> END OF MAIN' dump.
}
}