class: BookmarkList
authorClaus Gittinger <cg@exept.de>
Tue, 04 Nov 2014 12:13:55 +0100
changeset 14810 2e3231bb0b9e
parent 14809 9025aeaf760f
child 14811 1105a50bafa5
class: BookmarkList comment/format in: #readFrom:onError: changed: #readFromFile: #readFromFile:onError: duplicate code eliminated
BookmarkList.st
--- a/BookmarkList.st	Sat Nov 01 01:05:04 2014 +0100
+++ b/BookmarkList.st	Tue Nov 04 12:13:55 2014 +0100
@@ -85,8 +85,8 @@
 !
 
 readFrom: aStream onError: aBlock
+    | litArray |
 
-    | litArray |
     ^[
         litArray := Compiler evaluate: aStream contents asString.
         litArray decodeAsLiteralArray.
@@ -99,27 +99,18 @@
 !
 
 readFromFile: aStringOrFilename
-
-    | bookmarks file |
-    file := aStringOrFilename asFilename.
-    file exists ifFalse:
-        [self error: ('File does %1 not exists' bindWith: file pathName)].
-    bookmarks := self readFrom: file readStream onError: 
-        [self error: ('Cannot parse %1 not exists' bindWith: file pathName)].
-    bookmarks fileName: file pathName.
-    ^bookmarks
-
-    "Created: / 23-05-2011 / 16:10:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^ self readFromFile: aStringOrFilename onError:[:reason | self error:reason]
 !
 
 readFromFile: aStringOrFilename onError: aBlock
-    | bookmarks file |
+    | bookmarks file pathName|
 
     file := aStringOrFilename asFilename.
-    file exists ifFalse: [^aBlock value].
+    pathName := file pathName.
+    file exists ifFalse: [^ aBlock valueWithOptionalArgument:('File does %1 not exist' bindWith: pathName)].
     bookmarks := self readFrom: file readStream onError: [^aBlock value].
-    bookmarks isNil ifTrue: [^aBlock value].
-    bookmarks fileName: file pathName.
+    bookmarks isNil ifTrue: [^ aBlock valueWithOptionalArgument:('Cannot parse %1 not exist' bindWith: pathName)].
+    bookmarks fileName: pathName.
     ^bookmarks
 
     "Created: / 23-05-2011 / 16:32:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -406,10 +397,10 @@
 !BookmarkList class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/BookmarkList.st,v 1.7 2014-02-05 18:59:48 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/BookmarkList.st,v 1.8 2014-11-04 11:13:55 cg Exp $'
 !
 
 version_SVN
-    ^ '$Id: BookmarkList.st,v 1.7 2014-02-05 18:59:48 cg Exp $'
+    ^ '$Id: BookmarkList.st,v 1.8 2014-11-04 11:13:55 cg Exp $'
 ! !