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) ))))
|
||||
|
||||
Reference in New Issue
Block a user