Class: EmailErrorReporter::ErrorMailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
lib/email_error_reporter/error_mailer.rb

Instance Method Summary collapse

Instance Method Details

#error(error, handled:, severity:, context:, source: nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/email_error_reporter/error_mailer.rb', line 3

def error(error, handled:, severity:, context:, source: nil)
  @error = error
  @handled = handled
  @severity = severity
  @context = context
  @source = source

  @backtrace = Array.wrap(error.backtrace)

  severity_to_emoji = {
    error: "đŸ”Ĩ",
    warning: "âš ī¸",
    info: "â„šī¸"
  }

  mail(
    subject: "#{severity_to_emoji.fetch(@severity)}  #{error.class}",
    from: Rails.application.config.email_error_reporter.from,
    to: Rails.application.config.email_error_reporter.to
  )
end