URI.st
changeset 1251 7ee3093b7375
parent 1249 71aae2f2fbba
child 1254 baf01931b9d6
--- a/URI.st	Wed Jun 18 11:16:49 2003 +0200
+++ b/URI.st	Wed Jun 18 15:56:39 2003 +0200
@@ -13,7 +13,17 @@
 fromString:aString
     "create an URI from a given String"
 
-    ^ self fromString:aString onError:[self error:'conversion error'].
+    |i scheme rest|
+
+    i := aString indexOf:$:.
+    i == 0 ifTrue:[ 
+        self error:('Missing scheme in: %1!!' bindWith:aString)
+    ].
+    scheme := aString copyFrom:1 to:i-1.
+    rest := aString copyFrom:i+1.
+
+    ^ (self classForScheme:scheme) scheme:scheme fromString:rest
+
 
 
 "
@@ -24,21 +34,18 @@
 fromString:aString onError:exceptionBlock
     "create an URI from a given String"
 
-
-    ^ [ 
-        |i scheme rest|
+    |uri|
 
-        i := aString indexOf:$:.
-        i == 0 ifTrue:[ exceptionBlock value ] ifFalse:[
-            scheme := aString copyFrom:1 to:i-1.
-            rest := aString copyFrom:i+1.
-            (self classForScheme:scheme) scheme:scheme fromString:rest
-        ].
-    ] on:Error do:exceptionBlock
+    Error handle:[:ex| 
+        exceptionBlock value.
+    ] do:[
+        uri := self fromString:aString
+    ].
 
+    ^ uri
 
 "
-    self fromString:'' onError:nil  
+    self fromString:'' onError:nil    
 "
 ! !
 
@@ -201,5 +208,5 @@
 !URI class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/URI.st,v 1.2 2003-06-17 13:47:51 tm Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/URI.st,v 1.3 2003-06-18 13:56:39 tm Exp $'
 ! !