#handlerForSignal:context:originator:
authorStefan Vogel <sv@exept.de>
Mon, 15 Jul 2002 11:36:58 +0200
changeset 6628 4d693c525443
parent 6627 685ab6f994f0
child 6629 873db9bf2ff8
#handlerForSignal:context:originator:
Block.st
--- a/Block.st	Mon Jul 15 11:31:09 2002 +0200
+++ b/Block.st	Mon Jul 15 11:36:58 2002 +0200
@@ -1153,8 +1153,8 @@
     "evaluate the receiver.
      Optionally pass an argument (if the receiver is a one arg block)."
 
-    self numArgs == 1 ifTrue:[
-	^ self value:arg
+    nargs == 1 ifTrue:[
+        ^ self value:arg
     ].
     ^ self value
 
@@ -1171,38 +1171,31 @@
 
 !Block methodsFor:'exception handling'!
 
-handlerForSignal:signal context:theContext originator:originator
-    "answer the handler block for the signal from originator.
+handlerForSignal:exceptionHandler context:theContext originator:originator
+    "answer the handler block for the exceptionHandler from originator.
      The handler block is retrieved from aContext.
-     Answer nil if the signal is not handled."
+     Answer nil if the exceptionHandler is not handled."
 
-    |sig handler|
+    |exceptionHandlerInContext|
 
     theContext selector == #on:do: ifTrue:[
-        sig := theContext argAt:1.
-        sig isNil ifTrue:[
-            'Block [warning]: nil arg in on:do:-context (undefined Exception)' errorPrintCR.
+        exceptionHandlerInContext := theContext argAt:1.
+        exceptionHandlerInContext isExceptionHandler ifFalse:[
+            exceptionHandlerInContext isNil ifTrue:[
+                'Block [warning]: nil ExceptionHandler in on:do:-context' errorPrintCR.
+            ] ifFalse:[
+                'Block [warning]: non-ExceptionHandler in on:do:-context' errorPrintCR.
+            ].
             theContext fullPrint.
             ^ nil.
         ].
-        sig isSignalOrSignalSet ifFalse:[
-            'Block [warning]: non-Exception arg in on:do:-context' errorPrintCR.
-            theContext fullPrint.
-            ^ nil.
-        ].
-        (sig == signal or:[sig accepts:signal]) ifTrue:[
-            handler := theContext argAt:2.
-            "/ this is for backward compatibility when no ex-arg
-            "/ is expected in the block. Is it worth the effort ?
-            handler numArgs == 0 ifTrue:[
-                ^ [:ex | handler value]
-            ].
-            ^ handler
+        (exceptionHandlerInContext == exceptionHandler 
+         or:[exceptionHandlerInContext accepts:exceptionHandler]) ifTrue:[
+            ^ theContext argAt:2.
         ].
     ] ifFalse:[
         "must be #valueWithExceptionHandler:"
-        handler := theContext argAt:1.
-        ^ handler handlerForSignal:signal.
+        ^ (theContext argAt:1) handlerForSignal:exceptionHandler.
     ].
 
     ^ nil
@@ -1915,6 +1908,6 @@
 !Block class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.118 2002-07-10 09:21:44 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.119 2002-07-15 09:36:58 stefan Exp $'
 ! !
 Block initialize!