Created
December 6, 2017 13:34
-
-
Save igrishaev/951b26a7516a1a7e2d47dd90aac28958 to your computer and use it in GitHub Desktop.
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
(ns *.pcall | |
(:refer-clojure :exclude [try resolve]) | |
) | |
(bind ) | |
(defprotocol ITry) | |
(defrecord Try [ok result] | |
ITry | |
(ok? [_] ok) | |
(error? [_] (not ok)) | |
(resolve) | |
) | |
(let [http-response (....) | |
foo ( http-response (print )) | |
bar | |
]) | |
(defrecord) | |
(defn ok [x] [true x]) | |
(defn error [x] [false x]) | |
(defn ok? | |
) | |
(defmacro try [& body] | |
`(try | |
(let [result# (do ~@body)] | |
(ok result#)) | |
(catch Exception e# | |
(let [exp# (clojure.string/join \space '~body) | |
err# (-> e# .getMessage (or "unknown error")) | |
msg# (format "Error: %s, expression: %s" err# exp#)] | |
(error msg#))))) | |
(defn resolve | |
[pair] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment