Exception.st
changeset 2282 e019b9fb2977
parent 2257 1d9e88f6550e
child 2291 af7652b82404
--- a/Exception.st	Mon Jan 27 20:11:01 1997 +0100
+++ b/Exception.st	Mon Jan 27 20:29:13 1997 +0100
@@ -661,7 +661,7 @@
 
     theSignal := con receiver.
     theSignal isSignal ifFalse:[
-	self halt:'unexpected non-Signal in calling context'.
+        self halt:'unexpected non-Signal in calling context'.
     ].
 
 "/ 'search handler for: ' print. theSignal displayString printCR.
@@ -677,104 +677,102 @@
     "/ the code below collects active handlers ...
 
     [c notNil] whileTrue:[
-	c := c findContextWithSelector:#doRaise or:nil.
-	c notNil ifTrue:[
+        c := c findContextWithSelector:#doRaise or:nil.
+        c notNil ifTrue:[
 
-	    ex1 := c receiver.
-	    ((ex1 class == self class)
-	    or:[ex1 species == self species]) ifTrue:[
-		c := c sender.
-		(c notNil and:[c receiver == ex1]) ifTrue:[
-		    c := c sender.
-		    c notNil ifTrue:[
+            ex1 := c receiver.
+            ((ex1 class == self class)
+            or:[ex1 species == self species]) ifTrue:[
+                c := c sender.
+                (c notNil and:[c receiver == ex1]) ifTrue:[
+                    c := c sender.
+                    c notNil ifTrue:[
 
-			"/ the common case (really ?) first
-			((raiseReceiver := c receiver) == theSignal) ifTrue:[
-			    (c selector startsWith:'raise') ifTrue:[
-				h := ex1 handlerContext.
-				h notNil ifTrue:[
-				    activeHandlers isNil ifTrue:[
-					activeHandlers := OrderedCollection new
-				    ].
+                        "/ the common case (really ?) first
+                        ((raiseReceiver := c receiver) == theSignal) ifTrue:[
+                            (c selector startsWith:'raise') ifTrue:[
+                                h := ex1 handlerContext.
+                                h notNil ifTrue:[
+                                    activeHandlers isNil ifTrue:[
+                                        activeHandlers := OrderedCollection new
+                                    ].
 
-				    lastHandler := h.
-				    activeHandlers add:lastHandler.
-				    inHandler := true.
-				    c := lastHandler.
-				]
-			    ]
-			] ifFalse:[
-			    raiseReceiver isSignal ifTrue:[
-				(c selector startsWith:'raise') ifTrue:[
-				    h := ex1 handlerContext.
-				    h notNil ifTrue:[
-					(h receiver accepts:theSignal) ifTrue:[
+                                    lastHandler := h.
+                                    activeHandlers add:lastHandler.
+                                    inHandler := true.
+                                    c := lastHandler.
+                                ]
+                            ]
+                        ] ifFalse:[
+                            raiseReceiver isSignal ifTrue:[
+                                (c selector startsWith:'raise') ifTrue:[
+                                    h := ex1 handlerContext.
+                                    h notNil ifTrue:[
+                                        (h receiver accepts:theSignal) ifTrue:[
 
-					    activeHandlers isNil ifTrue:[
-						activeHandlers := OrderedCollection new
-					    ].
-					    lastHandler := h.
-					    activeHandlers add:lastHandler.
-					    inHandler := true.
-					    c := lastHandler.
-					]
-				    ]    
-				]    
-			    ]    
-			]
-		    ]
-		]
-	    ].
-	    c := c sender.
-	]
+                                            activeHandlers isNil ifTrue:[
+                                                activeHandlers := OrderedCollection new
+                                            ].
+                                            lastHandler := h.
+                                            activeHandlers add:lastHandler.
+                                            inHandler := true.
+                                            c := lastHandler.
+                                        ]
+                                    ]    
+                                ]    
+                            ]    
+                        ]
+                    ]
+                ]
+            ].
+            c := c sender.
+        ]
     ].
 
     "/ now, start searching for a handler,
     "/ start search above the last active handler
 
     lastHandler notNil ifTrue:[
-	con := lastHandler sender.
+        con := lastHandler sender.
     ].
 
     any := false.
     [con notNil] whileTrue:[
-	con isBlockContext ifFalse:[
-
-	    sel := con selector.
+        con := con findContextWithSelector:#'handle:do:' or:#'handle:from:do:'.
+        con notNil ifTrue:[
+            (con selector == #'handle:do:'
+            or:["sel = #'handle:from:do:'"
+                (con argAt:2) == originator]) ifTrue:[
 
-	    ((sel == #'handle:do:') 
-	    or:[((sel == #'handle:from:do:') 
-		and:[(con argAt:2) == originator])]) ifTrue:[
-
-		"/ new behavior:
-		(activeHandlers notNil
-		 and:[activeHandlers includesIdentical:con]) ifTrue:[
-		    'skip activeHandler: ' print. con displayString printCR.
+                "/ new behavior:
+                (activeHandlers notNil
+                 and:[activeHandlers includesIdentical:con]) ifTrue:[
+                    'skip activeHandler: ' print. con displayString printCR.
 
-		] ifFalse:[
-		    "
-		     if this is the Signal>>handle:do: context
-		     or a SignalSet>>handle:do: context with self in it,
-		     call the handler
-		    "
-		    (con receiver accepts:signal) ifTrue:[
-			"call the handler"
+                ] ifFalse:[
+                    "
+                     if this is the Signal>>handle:do: context
+                     or a SignalSet>>handle:do: context with self in it,
+                     call the handler
+                    "
+                    (con receiver accepts:signal) ifTrue:[
+                        "call the handler"
 
-			conArg1 := con argAt:1.
+                        conArg1 := con argAt:1.
 
-			handlerContext := con.
-			any := true.
+                        handlerContext := con.
+                        any := true.
 
-			self doCallHandler:conArg1.
+                        self doCallHandler:conArg1.
 
-			"if the handler rejects, we arrive here"
-			"continue search for another handler"
-			rejected := true.
-		    ].
-		]
-	    ]
-	].
-	con := con sender
+                        "if the handler rejects, we arrive here"
+                        "continue search for another handler"
+                        rejected := true.
+                    ].
+                ]
+            ].
+            con := con sender
+        ].
     ].
 
     activeHandlers := nil.
@@ -787,58 +785,58 @@
      try per signal handler
     "
     (block := signal handlerBlock) isNil ifTrue:[
-	"/
-	"/ if its a querySignal, ignore it
-	"/
-	signal isQuerySignal ifTrue:[^ nil].
+        "/
+        "/ if its a querySignal, ignore it
+        "/
+        signal isQuerySignal ifTrue:[^ nil].
 
-	"/
-	"/ if it is not the NoHandlerSignal, raise it ...
-	"/ passing the receiver as parameter.
-	"/
-	signal ~~ (noHandlerSignal := Signal noHandlerSignal) ifTrue:[
-	    noHandlerSignal notNil ifTrue:[
-		any ifTrue:[
-		    msg := 'unhandled (rejected)'
-		] ifFalse:[
-		    msg := 'unhandled'
-		].
-		msg := msg , ' exception: (' , errorString , ')'.
-		^ noHandlerSignal 
-		      raiseRequestWith:self 
-			   errorString:msg
-				    in:self suspendedContext
-	    ].
-	    "/
-	    "/ mhmh - an error during early startup; noHandlerSignal is
-	    "/ not yet defined.
-	    "/
-	    ^ MiniDebugger enterWithMessage:errorString
-	].
+        "/
+        "/ if it is not the NoHandlerSignal, raise it ...
+        "/ passing the receiver as parameter.
+        "/
+        signal ~~ (noHandlerSignal := Signal noHandlerSignal) ifTrue:[
+            noHandlerSignal notNil ifTrue:[
+                any ifTrue:[
+                    msg := 'unhandled (rejected)'
+                ] ifFalse:[
+                    msg := 'unhandled'
+                ].
+                msg := msg , ' exception: (' , errorString , ')'.
+                ^ noHandlerSignal 
+                      raiseRequestWith:self 
+                           errorString:msg
+                                    in:self suspendedContext
+            ].
+            "/
+            "/ mhmh - an error during early startup; noHandlerSignal is
+            "/ not yet defined.
+            "/
+            ^ MiniDebugger enterWithMessage:errorString
+        ].
 
-	"
-	 mhmh - smells like trouble - there is no handler and
-	 no per-signal handler block.
-	 Look for either a per-process emergencyHandlerBlock 
-	 or the global emergencyHandler (from Exception) ...
-	"
-	Processor notNil ifTrue:[ 
-	    "care for signal during startup (Processor not yet created)"
-	    block := Processor activeProcess emergencySignalHandler.
-	].
-	block isNil ifTrue:[
-	    block := Exception emergencyHandler.
-	    block isNil ifTrue:[
-		"care for error during startup (Exception not yet initialized)"
-		^ MiniDebugger enterWithMessage:errorString
-	    ].
-	].
+        "
+         mhmh - smells like trouble - there is no handler and
+         no per-signal handler block.
+         Look for either a per-process emergencyHandlerBlock 
+         or the global emergencyHandler (from Exception) ...
+        "
+        Processor notNil ifTrue:[ 
+            "care for signal during startup (Processor not yet created)"
+            block := Processor activeProcess emergencySignalHandler.
+        ].
+        block isNil ifTrue:[
+            block := Exception emergencyHandler.
+            block isNil ifTrue:[
+                "care for error during startup (Exception not yet initialized)"
+                ^ MiniDebugger enterWithMessage:errorString
+            ].
+        ].
     ].
     "... and call it"
     ^ block value:self.
 
     "Created: 12.5.1996 / 15:09:39 / cg"
-    "Modified: 9.11.1996 / 17:04:28 / cg"
+    "Modified: 27.1.1997 / 20:26:06 / cg"
 !
 
 raise
@@ -877,6 +875,6 @@
 !Exception class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Exception.st,v 1.48 1997-01-24 19:37:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Exception.st,v 1.49 1997-01-27 19:29:13 cg Exp $'
 ! !
 Exception initialize!