chore: Handle Sentry Errors (#2020)

If a contract contains an invalid email address, the sidekiq jobs for conversation continuity would error out. handling this exception gracefully.
This commit is contained in:
Sojan Jose
2021-03-30 21:06:31 +05:30
committed by GitHub
parent 71214b59d8
commit bb37f7b263
2 changed files with 12 additions and 2 deletions

View File

@@ -16,12 +16,19 @@ class ApplicationMailer < ActionMailer::Base
end
end
rescue_from(*ExceptionList::SMTP_EXCEPTIONS, with: :handle_smtp_exceptions)
def smtp_config_set_or_development?
ENV.fetch('SMTP_ADDRESS', nil).present? || Rails.env.development?
end
private
def handle_smtp_exceptions(message)
Rails.logger.info 'Failed to send Email'
Rails.logger.info "Exception: #{message}"
end
def send_mail_with_liquid(*args)
mail(*args) do |format|
# explored sending a multipart email containing both text type and html

View File

@@ -1,5 +1,8 @@
module ExceptionList
URI_EXCEPTIONS = [Errno::ETIMEDOUT, Errno::ECONNREFUSED, URI::InvalidURIError, Net::OpenTimeout, SocketError].freeze
URI_EXCEPTIONS = [Errno::ETIMEDOUT, Errno::ECONNREFUSED, URI::InvalidURIError, Net::OpenTimeout, SocketError, OpenURI::HTTPError].freeze
REST_CLIENT_EXCEPTIONS = [RestClient::NotFound, RestClient::GatewayTimeout, RestClient::BadRequest,
RestClient::MethodNotAllowed, RestClient::Forbidden].freeze
RestClient::MethodNotAllowed, RestClient::Forbidden, RestClient::InternalServerError, RestClient::PayloadTooLarge].freeze
SMTP_EXCEPTIONS = [
Net::SMTPSyntaxError
].freeze
end