added: #withErrorStreamDo:
authorClaus Gittinger <cg@exept.de>
Thu, 21 Apr 2011 12:47:33 +0200
changeset 13350 8c7603161369
parent 13349 07d793af5c59
child 13351 aeaf4e1b3dbb
added: #withErrorStreamDo: changed: #errorPrint #errorPrintCR
Object.st
--- a/Object.st	Thu Apr 21 12:43:19 2011 +0200
+++ b/Object.st	Thu Apr 21 12:47:33 2011 +0200
@@ -517,6 +517,9 @@
     "Modified: 23.4.1996 / 16:00:07 / cg"
 ! !
 
+
+
+
 !Object methodsFor:'Compatibility-Dolphin'!
 
 stbFixup: anSTBInFiler at: newObjectIndex
@@ -678,6 +681,7 @@
     "
 ! !
 
+
 !Object methodsFor:'accessing'!
 
 _at:index
@@ -1685,6 +1689,7 @@
     "Modified: / 18.2.2000 / 11:32:19 / cg"
 ! !
 
+
 !Object methodsFor:'change & update'!
 
 broadcast:aSelectorSymbol
@@ -1874,6 +1879,7 @@
     ^ self
 ! !
 
+
 !Object methodsFor:'comparing'!
 
 = anObject
@@ -2122,7 +2128,6 @@
 %}
 ! !
 
-
 !Object methodsFor:'converting'!
 
 -> anObject
@@ -6434,19 +6439,9 @@
      The Transcript is directed to the standard error stream on
      headless applications."
 
-    |s|
-
-    s := Processor activeProcess isSystemProcess
-			ifTrue:Stderr
-			ifFalse:Transcript.
-    StreamError catch:[
-	self printOn:s
-    ].
-"/    s ~~ Stderr ifTrue:[
-"/        self printOn:Stderr
-"/    ].
-
-    "Modified: / 29-05-2007 / 20:00:54 / cg"
+    self withErrorStreamDo:[:s | self printOn:s].
+
+    "Modified: / 21-04-2011 / 12:46:42 / cg"
 !
 
 errorPrintCR
@@ -6456,22 +6451,14 @@
      The Transcript is directed to the standard error stream on
      headless applications."
 
-    |s|
-
-    s := Processor activeProcess isSystemProcess
-			ifTrue:Stderr
-			ifFalse:Transcript.
-    StreamError catch:[
-	self printOn:s.
-	s cr
-    ].
-"/    s ~~ Stderr ifTrue:[
-"/        self printOn:Stderr.
-"/        Stderr cr
-"/    ].
+    self withErrorStreamDo:[:s | self printOn:s. s cr].
+
+    "
+     'hello' errorPrintCR
+    "
 
     "Created: / 20-05-1996 / 10:20:41 / cg"
-    "Modified: / 29-05-2007 / 20:00:49 / cg"
+    "Modified: / 21-04-2011 / 12:47:13 / cg"
 !
 
 errorPrintNL
@@ -7025,6 +7012,24 @@
     s := WriteStream on:(String new:50).
     self storeOn:s.
     ^ s contents
+!
+
+withErrorStreamDo:aBlock
+    "{ Pragma: +optSpace }"
+
+    "helper for error messages - evaluate alock, passing it a stream on which to put
+     error messages."
+
+    |s|
+
+    s := Processor activeProcess isSystemProcess
+                        ifTrue:Stderr
+                        ifFalse:Transcript.
+    StreamError catch:[
+        aBlock value:s.
+    ].
+
+    "Created: / 21-04-2011 / 12:46:21 / cg"
 ! !
 
 !Object methodsFor:'queries'!
@@ -7215,6 +7220,7 @@
     ^ self
 ! !
 
+
 !Object methodsFor:'secure message sending'!
 
 ?: selector
@@ -7817,6 +7823,7 @@
     "
 ! !
 
+
 !Object methodsFor:'synchronized evaluation'!
 
 freeSynchronizationSemaphore
@@ -9378,11 +9385,11 @@
 !Object class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.664 2011-03-21 13:16:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.665 2011-04-21 10:47:33 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.664 2011-03-21 13:16:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.665 2011-04-21 10:47:33 cg Exp $'
 ! !
 
 Object initialize!