]> gitweb.factorcode.org Git - factor.git/commitdiff
basis,extra: refactorings to use the ignore-error and ignore-error/f words
authorBjörn Lindqvist <bjourne@gmail.com>
Fri, 18 Nov 2016 22:39:53 +0000 (23:39 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Fri, 18 Nov 2016 22:41:36 +0000 (23:41 +0100)
basis/compiler/tree/builder/builder.factor
basis/compiler/tree/propagation/call-effect/call-effect.factor
basis/furnace/auth/providers/couchdb/couchdb.factor
basis/io/files/info/windows/windows.factor
basis/io/monitors/windows/windows.factor
basis/listener/listener.factor
extra/couchdb/couchdb.factor

index 3670168c3eb0e827543db097ad6556ea560cff06..624a54a95b924f72e84f8d8a2d2d25f6c6fafbe6 100644 (file)
@@ -46,4 +46,4 @@ PRIVATE>
             { [ dup ends-with-terminate? ] [ out-d [ f swap <#push> ] map append ] }
             [ in-d' out-d [ [ length ] bi@ assert= ] [ <#copy> suffix ] 2bi ]
         } cond
-    ] [ dup inference-error? [ drop f ] [ rethrow ] if ] recover ;
+    ] [ inference-error? ] ignore-error/f ;
index edb5ce76bae4cef9f0cc0ad0d038409ebcd78403..9b49930d438026234309f941327db567e557c7ff 100644 (file)
@@ -156,9 +156,7 @@ ERROR: uninferable ;
     ] if ;
 
 : infer-value ( value-info -- effect/f )
-    [ (infer-value) ]
-    [ dup uninferable? [ 2drop f ] [ rethrow ] if ]
-    recover ;
+    '[ _ (infer-value) ] [ uninferable? ] ignore-error/f ;
 
 : (value>quot) ( value-info -- quot )
     dup literal?>> [
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 ] [
index 962925362234cb68cb99c8ff621cb24b1eed0111..8949be44818ddcb7a881c5b31a7f398c5e902eb6 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: byte-arrays math io.backend io.files.info
+USING: byte-arrays fry math io.backend io.files.info
 io.files.windows kernel windows.kernel32
 windows.time windows.types windows accessors alien.c-types
 combinators generalizations system alien.strings
@@ -213,12 +213,10 @@ CONSTANT: names-buf-length 16384
     ] with-destructors ;
 
 ! Suppress T{ windows-error f 2 "The system cannot find the file specified." }
-: volume>paths ( string -- array )
-    [ (volume>paths) ] curry
-    [
-        dup { [ windows-error? ] [ n>> ERROR_FILE_NOT_FOUND = ] } 1&&
-        [ drop { } ] [ rethrow ] if
-    ] recover ;
+: volume>paths ( string -- array/f )
+    '[ _ (volume>paths) ] [
+        { [ windows-error? ] [ n>> ERROR_FILE_NOT_FOUND = ] } 1&&
+    ] ignore-error/f ;
 
 ! Can error with T{ windows-error f 21 "The device is not ready." }
 ! if there is a D: that is not ready, for instance. Ignore these drives.
index 434437dddc82d4d28cad630abeec665075c859d0..4c99ca18c85f0628b2bf7c30863567fa51d0a0df 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.data arrays classes.struct
-combinators continuations destructors io.backend
+combinators continuations destructors fry io.backend
 io.encodings.string io.encodings.utf16n io.files.windows
 io.monitors io.pathnames io.ports kernel literals locals make
 math sequences system threads windows.errors windows.kernel32
@@ -85,8 +85,8 @@ TUPLE: win32-monitor < monitor port ;
     dup fill-queue (fill-queue-thread) ;
 
 : fill-queue-thread ( monitor -- )
-    [ dup fill-queue (fill-queue-thread) ]
-    [ dup already-disposed? [ 2drop ] [ rethrow ] if ] recover ;
+    '[ _ dup fill-queue (fill-queue-thread) ]
+    [ already-disposed? ] ignore-error ;
 
 M:: windows (monitor) ( path recursive? mailbox -- monitor )
     [
index d1cea41e28212c95b1b4b4b2a974da8731a9b7cf..12e8b1ebf57ede2495c045ac33f6f0d6d35216cd 100644 (file)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2003, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors colors colors.constants
-combinators.short-circuit compiler.units continuations debugger
-fry io io.styles kernel lexer literals locals math math.parser
-namespaces parser parser.notes prettyprint sequences sets
-source-files.errors system vocabs vocabs.loader
+USING: accessors colors colors.constants combinators.short-circuit
+compiler.units continuations debugger fry io io.styles kernel lexer
+locals math math.parser namespaces parser parser.notes prettyprint
+sequences sets source-files.errors system vocabs vocabs.loader
 vocabs.parser ;
 IN: listener
 
@@ -40,10 +39,8 @@ SYMBOL: handle-ctrl-break
     [ [ parse-lines ] with-ctrl-break ] with-compilation-unit ;
 
 : read-quot-step ( lines -- quot/f )
-    [ parse-lines-interactive ] [
-        dup error>> unexpected-eof?
-        [ 2drop f ] [ rethrow ] if
-    ] recover ;
+    '[ _ parse-lines-interactive ]
+    [ error>> unexpected-eof? ] ignore-error/f ;
 
 : read-quot-loop ( stream accum -- quot/f )
     over stream-readln dup [
index 0de1cb95b8bbf6de0027ab0bebf5c42933d80a36..15db1920e1d3934557a7f3a549b6110d3fa24bf9 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008, 2009 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs continuations debugger hashtables http
+USING: accessors assocs continuations debugger fry hashtables http
 http.client io io.encodings.string io.encodings.utf8 json.reader
 json.writer kernel locals make math math.parser namespaces sequences
-strings urls urls.encoding vectors ;
+strings urls.encoding vectors ;
 IN: couchdb
 
 ! NOTE: This code only works with the latest couchdb (0.9.*), because old
@@ -111,9 +111,7 @@ C: <db> db
     f swap db-url couch-put response-ok* ;
 
 : ensure-db ( db -- )
-    [ create-db ] [
-        dup file-exists-error? [ 2drop ] [ rethrow ] if
-    ] recover ;
+    '[ _ create-db ] [ file-exists-error? ] ignore-error ;
 
 : delete-db ( db -- )
     db-url couch-delete drop ;