July 2017
Intermediate to advanced
284 pages
6h 45m
English
It gets even better.
If you know in advance some of the strategies your callers might want to pursue in dealing with an error, you can name those strategies at the point of a possible error, and then let callers select a strategy by name. The bind-continue form takes the name of a strategy, an argument list, and a form to implement the strategy.
So, continuing with our log example, you might choose to provide explicit skip and log strategies for dealing with a parse error:
| | (defn parse-or-continue [logseq] |
| | (let [parse-log-entry |
| | (fn [entry] |
| | (with-handler (parse-log-entry entry) |
| | (bind-continue skip [msg] |
| | nil) |
| | (bind-continue log [msg] |
| | (println "****invalid log: " msg))))] |
| | (vec (map parse-log-entry ... |
Read now
Unlock full access