GenericException.st
branchjv
changeset 17732 a1892eeca6c0
parent 17728 bbc5fa73dfab
child 17734 406b1590afe8
--- a/GenericException.st	Fri Aug 28 12:38:51 2009 +0100
+++ b/GenericException.st	Sat Oct 24 16:48:19 2009 +0100
@@ -341,6 +341,14 @@
     ^ SignalSet with:self with:anExceptionHandler
 ! !
 
+!GenericException class methodsFor:'misc ui support'!
+
+iconInBrowserSymbol
+    <resource: #programImage>
+
+    ^ #exceptionClassBrowserIcon
+! !
+
 !GenericException class methodsFor:'printing'!
 
 description
@@ -918,6 +926,21 @@
     "Modified: / 07-12-2006 / 17:05:28 / cg"
 !
 
+evaluate:aBlock ifRaised:exceptionValue
+    "evaluate the argument, aBlock and return its value.
+     If the receiver-signal is raised during evaluation, abort
+     the evaluation and return the value from exceptionValue. 
+     This is similar to the catch & throw mechanism found in other languages"
+
+    ^ self handle:[:ex | exceptionValue value] do:aBlock.
+
+    "
+     Object messageNotUnderstoodSignal 
+        evaluate:[ 123 size open ]
+        ifRaised:345         
+    "
+!
+
 handle:handleBlock do:aBlock
     "evaluate the argument, aBlock.
      If the receiver-exception is raised during evaluation,
@@ -1572,6 +1595,23 @@
      ].
      rslt
     "
+
+    "
+     |rslt firstTime|
+
+     firstTime := true.
+     ZeroDivide handle:[:ex |
+        firstTime ifTrue:[
+            Dialog information:'again...'.
+            firstTime := false.
+            ex resignalAs:ZeroDivide.
+        ].
+        Dialog information:'arrived here again...'.
+     ] do:[
+        rslt := 5 // 0
+     ].
+     rslt
+    "
 !
 
 restart
@@ -2060,7 +2100,12 @@
 !GenericException class methodsFor:'documentation'!
 
 version
-    ^ '$Id: GenericException.st 10467 2009-08-19 16:14:36Z vranyj1 $'
+    ^ '$Id: GenericException.st 10473 2009-10-24 15:48:19Z vranyj1 $'
+!
+
+version_CVS
+    ^ '§Header: /cvs/stx/stx/libbasic/GenericException.st,v 1.120 2009/10/06 10:15:04 cg Exp §'
 ! !
 
 GenericException initialize!
+