Reputation: 17392
Similar to Clojure recur with multi-arity I'd like recur with a different arity. But in my case, I define the function via a let, as I want to use another value from the let (file-list
) without passing it:
(let [file-list (drive/list-files! google-drive-credentials google-drive-folder-id)
download-file (fn
([name]
(download-file ; <-- attempt to recur
name
(fn []
(throw
(ex-info
(str name " not found on Google Drive"))))))
([name not-found-fn]
(if-let [file (->> file-list
(filter #(= (:original-filename %)
name))
first)]
(drive/download-file! google-drive-credentials file)
(not-found-fn))))]
;; #
)
I get this error: Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: download-file in this context
Upvotes: 2
Views: 724
Reputation: 29958
In order to make more readable exception error messages, I often append -fn
to the inner function name, like so:
(let [download-file (fn download-file-fn [name] ...) ]
<use download-file> ...)
Upvotes: -1