Handle sending mail more properly

With custom sentry reporting issues

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-04-20 15:02:24 +02:00
parent 9a65b29640
commit d98e68203e
10 changed files with 46 additions and 18 deletions

View File

@@ -3,4 +3,32 @@ defmodule Mobilizon.Web.Email.Mailer do
Mobilizon Mailer.
"""
use Bamboo.Mailer, otp_app: :mobilizon
def send_email_later(email) do
try do
Mobilizon.Web.Email.Mailer.deliver_later!(email)
rescue
error ->
Sentry.capture_exception(error,
stacktrace: __STACKTRACE__,
extra: %{extra: "Error while sending email"}
)
reraise error, __STACKTRACE__
end
end
def send_email(email) do
try do
Mobilizon.Web.Email.Mailer.deliver_now!(email)
rescue
error ->
Sentry.capture_exception(error,
stacktrace: __STACKTRACE__,
extra: %{extra: "Error while sending email"}
)
reraise error, __STACKTRACE__
end
end
end