Skip to content

Instantly share code, notes, and snippets.

@igrishaev
Created December 6, 2017 13:34
Show Gist options
  • Save igrishaev/951b26a7516a1a7e2d47dd90aac28958 to your computer and use it in GitHub Desktop.
Save igrishaev/951b26a7516a1a7e2d47dd90aac28958 to your computer and use it in GitHub Desktop.
(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