more detection of problems.

This commit is contained in:
2022-07-11 12:33:29 -07:00
parent 3e6a1e6eba
commit c37af2a188

View File

@@ -249,13 +249,17 @@
(catch Exception e
(log/warn "error pulling http " e)
(retry f (inc i))))
(log/error "Too many failures"))))
(log/warn "Too many failures"))))
(defn get-payment [client p]
(:payment (:body (retry #(client/get (str "https://connect.squareup.com/v2/payments/" p)
{:headers (client-base-headers client)
:as :json
:retry-handler retry-4})))))
(defn halt-if-error [x]
(if (instance? Throwable x)
(throw x)
x))
(defn get-settlement-sales-date [client settlement]
(let [concurrent 10
@@ -281,8 +285,10 @@
true
(fn [e]
(lc/with-context {:source "Square settlements loading "}
(log/error "Error loading sales date details" e))))
(log/warn "Error loading sales date details" e)
e)))
(->> (async/<!! (async/into [] output-chan))
(map halt-if-error)
sort
(drop 2)
first)))
@@ -308,8 +314,10 @@
true
(fn [e]
(lc/with-context {:source "Square settlements loading "}
(log/error "Error loading settlements details" e))))
(async/<!! (async/into [] output-chan))))
(log/warn "Error loading settlements details" e)
e)))
(->> (async/<!! (async/into [] output-chan))
(map halt-if-error))))
(defn settlements
([client location] (settlements client location (lookup-dates)))