minor fixes

This commit is contained in:
Bryce Covert
2023-01-06 16:39:56 -08:00
parent f502d0974e
commit e0ca794254
2 changed files with 0 additions and 56 deletions

View File

@@ -2,7 +2,6 @@
(:require
[auto-ap.datomic :refer [conn remove-nils]]
[auto-ap.time :as atime]
[auto-ap.async-error :as aerror]
[clj-http.client :as client]
[clj-time.coerce :as coerce]
[clj-time.core :as time]
@@ -16,7 +15,6 @@
[cemerick.url :as url]
[datomic.api :as d]
[slingshot.slingshot :refer [try+]]
[unilog.context :as lc]
[manifold.executor :as ex]
[manifold.deferred :as de]
[manifold.time :as mt]

View File

@@ -1,54 +0,0 @@
(ns auto-ap.async-error
#?(:clj
(:require [clojure.core.async])))
;; ---- Helpers Taken from Prismatic Schema -----------------------------------
#?(:clj
(defn cljs-env?
"Take the &env from a macro, and tell whether we are expanding into cljs."
[env]
(boolean (:ns env))))
#?(:clj
(defmacro if-cljs
"Return then if we are generating cljs code and else for Clojure code.
https://groups.google.com/d/msg/clojurescript/iBY5HaQda4A/w1lAQi9_AwsJ"
[then else]
(if (cljs-env? &env) then else)))
;; ---- Helpers ---------------------------------------------------------------
(defn throw-err [e]
(when (instance? #?(:clj Throwable :cljs js/Error) e) (throw e))
e)
;; ---- Public API ------------------------------------------------------------
#?(:clj
(defmacro <?
"Like <! but throws errors."
[ch]
`(if-cljs
(throw-err (cljs.core.async/<! ~ch))
(throw-err (clojure.core.async/<! ~ch)))))
#?(:clj
(defn <??
"Like <!! but throws errors."
[ch]
(throw-err (clojure.core.async/<!! ch))))
#?(:clj
(defmacro go-try
"Like go but catches the first thrown error and returns it."
[& body]
`(if-cljs
(cljs.core.async/go
(try
~@body
(catch js/Error e# e#)))
(clojure.core.async/go
(try
~@body
(catch Throwable t# t#))))))