taking care of errros.

This commit is contained in:
2021-11-25 08:36:24 -08:00
parent b0afa05c2e
commit 1d32f19ce3
3 changed files with 23 additions and 8 deletions

View File

@@ -128,7 +128,10 @@
(when (nil? (:account_id expense-account))
(throw (ex-info "Expense account is missing account" {:validation-error "Expense account is missing account"})))))
(throw (ex-info "Expense account is missing account" {:validation-error "Expense account is missing account"})))
(when (nil? (:amount expense-account))
(throw (ex-info "Expense account does not have an amount specified." {:validation-error "Expense account does not have an amount specified."})))))
(defn assert-invoice-amounts-add-up [{:keys [expense_accounts total]}]

View File

@@ -66,7 +66,7 @@
:else
(do
(log/error "couldn't look up" i)
(log/warn "couldn't look up" i)
"Uncategorized"))))
(defn categories []

View File

@@ -25,6 +25,16 @@
(log/error "yodlee Error." ex)
false)}))
(defn retry-thrice
([x] (retry-thrice x 0))
([x i]
(try
(x)
(catch Exception e
(if (>= i 3)
(throw e)
(retry-thrice x (inc i)))))))
(def base-headers {"Api-Version" "1.1"
"Cobrand-Name" (:yodlee-cobrand-name env)
"Content-Type" "application/json"})
@@ -75,12 +85,14 @@
(try
(let [cob-session (login-cobrand)
user-session (login-user cob-session)]
(-> (str (:yodlee-base-url env) "/accounts?providerAccountId=" provider-account-id)
(client/get (merge {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)})
:as :json}
other-config))
:body
:account))
(retry-thrice
(fn []
(-> (str (:yodlee-base-url env) "/accounts?providerAccountId=" provider-account-id)
(client/get (merge {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)})
:as :json}
other-config))
:body
:account))))
(catch Exception e
(log/error (str "Couldn't get accounts for provider account '" provider-account-id "'")
e)