include more details when error happens importing
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
(javax.mail Session)
|
||||
(javax.mail.internet MimeMessage)))
|
||||
|
||||
(defn send-email-about-failed-message [mail-bucket mail-key]
|
||||
(defn send-email-about-failed-message [mail-bucket mail-key message]
|
||||
(let [target-key (str "failed-emails/" mail-key ".eml")
|
||||
target-url (str "http://" (:data-bucket env)
|
||||
".s3-website-us-east-1.amazonaws.com/"
|
||||
@@ -28,7 +28,7 @@
|
||||
(ses/send-email {:destination {:to-addresses (:import-failure-destination-emails env)}
|
||||
:source (:invoice-email env)
|
||||
:message {:subject "An email invoice import failed"
|
||||
:body {:html (str "<div>You can download the original email <a href=\"" target-url "\">here</a>.</div>")
|
||||
:body {:html (str "<div>You can download the original email <a href=\"" target-url "\">here</a>.<p><pre>" message "</pre></p></div>")
|
||||
:text (str "<div>You can download the original email here: " target-url)}}})))
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@
|
||||
(alog/info ::found-imports :imports imports)
|
||||
(invoices/import-uploaded-invoice {:user/role "admin"} imports ))))
|
||||
(catch Exception e
|
||||
(alog/warn ::cant-import e)
|
||||
(send-email-about-failed-message (-> r :s3 :bucket :name) (-> r :s3 :object :key)))
|
||||
(alog/warn ::cant-import :error e)
|
||||
(send-email-about-failed-message (-> r :s3 :bucket :name) (-> r :s3 :object :key)) (str e))
|
||||
(finally
|
||||
(io/delete-file filename))))))))
|
||||
(sqs/delete-message (assoc message :queue-url (:invoice-import-queue-url env) ))))
|
||||
|
||||
@@ -12,9 +12,17 @@
|
||||
\"foo[bar][][baz]\"
|
||||
=> [\"foo\" \"bar\" \"\" \"baz\"]"
|
||||
[param-name]
|
||||
(let [[_ k ks] (re-matches #"(?s)(.*?)((?:\[.*?\])*)" (name param-name))
|
||||
keys (if ks (map second (re-seq #"\[(.*?)\]" ks)))]
|
||||
(cons k keys)))
|
||||
(let [[_ k ks] (re-matches #"(?s)(.*?)((?:(\[.*?\])|\(.*?\))*)" (name param-name))
|
||||
keys (if ks (map second (re-seq #"(\[.*?\]|\(.*?\))" ks)))]
|
||||
(cons k
|
||||
(map (fn [k]
|
||||
(let [[_ indexed-match] (re-matches k "\((.*?)\)")
|
||||
[_ keyed-match] (re-matches k "\[(.*?)\]")]
|
||||
(if indexed-match
|
||||
[:index indexed-match]
|
||||
[:key indexed-match])))))))
|
||||
|
||||
|
||||
|
||||
(defn- assoc-vec [m k v]
|
||||
(let [m (if (contains? m k) m (assoc m k []))]
|
||||
|
||||
Reference in New Issue
Block a user