Created
November 1, 2015 22:48
-
-
Save stevebuik/f97901dda45926313e1c to your computer and use it in GitHub Desktop.
An example of logging and sanitizing server parsers exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn handle | |
[env params] | |
(let [p (parser {:read readf | |
:mutate mutatef}) | |
result (p env params) | |
errors (->> result | |
(filter (fn [[k v]] (instance? Throwable v))))] | |
(if (seq errors) | |
(do | |
(doseq [[req res] errors] | |
(error res)) | |
(->> result | |
(map (fn [[k v]] | |
[k (if (instance? Throwable v) | |
:operation-failed | |
v)])) | |
(into {}))) | |
result))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment