]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/furnace/auth/providers/couchdb/couchdb.factor
basis,extra: refactorings to use the ignore-error and ignore-error/f words
[factor.git] / basis / furnace / auth / providers / couchdb / couchdb.factor
index 62accc64106a12a3bdaf82cd07d1f100aea0b754..a01c80baaccd1498ab2e119dab078d6b0d1152ca 100644 (file)
@@ -1,8 +1,6 @@
-USING: accessors assocs couchdb furnace.auth.providers
-json.writer kernel mirrors sequences urls urls.encoding
-arrays furnace.auth byte-arrays combinators.short-circuit
-strings continuations combinators base64 make
-locals namespaces ;
+USING: accessors assocs base64 byte-arrays combinators.short-circuit
+continuations couchdb fry furnace.auth.providers json.writer kernel
+locals make mirrors namespaces sequences strings urls urls.encoding ;
 IN: furnace.auth.providers.couchdb
 
 ! !!! Implement the authentication protocol for CouchDB.
@@ -57,13 +55,10 @@ TUPLE: couchdb-auth-provider
     prefix>> [ % url-encode-full % "!" % url-encode-full % ] "" make ;
 
 : (reserve) ( value name -- id/f )
-    reservation-id
-    get-url
-    [
-        H{ } clone >json swap couch-put
-    ] [
-        nip dup is-couchdb-conflict-error? [ drop f ] [ rethrow ] if
-    ] recover ;
+    '[
+        _ _ reservation-id get-url
+        H{ } clone swap couch-put
+    ] [ is-couchdb-conflict-error? ] ignore-error/f ;
 
 ! Don't reserve false values (e.g. if the email field is f, don't reserve f,
 ! or the first user who registers without an email address will block all
@@ -78,13 +73,11 @@ TUPLE: couchdb-auth-provider
     couch-delete drop ;
 
 : unreserve-from-id ( id -- )
-    [
-        get-url dup couch-get
+    '[
+        get-url dup couch-get
         "_rev" of "rev" set-query-param
         couch-delete drop
-    ] [
-        dup is-couchdb-not-found-error? [ 2drop ] [ rethrow ] if
-    ] recover ;
+    ] [ is-couchdb-not-found-error? ] ignore-error ;
 
 :: (reserve-multiple) ( hash keys made -- ? )
     keys empty? [ t ] [