Class: ExceptionNotifier::Notifier
- Inherits:
-
ActionMailer::Base
- Object
- ActionMailer::Base
- ExceptionNotifier::Notifier
show all
- Defined in:
- lib/exception_notifier/notifier.rb
Defined Under Namespace
Classes: MissingController
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.default_email_prefix ⇒ Object
18
19
20
|
# File 'lib/exception_notifier/notifier.rb', line 18
def default_email_prefix
"[ERROR] "
end
|
.default_exception_recipients ⇒ Object
14
15
16
|
# File 'lib/exception_notifier/notifier.rb', line 14
def default_exception_recipients
[]
end
|
.default_options ⇒ Object
26
27
28
29
30
31
|
# File 'lib/exception_notifier/notifier.rb', line 26
def default_options
{ :sender_address => default_sender_address,
:exception_recipients => default_exception_recipients,
:email_prefix => default_email_prefix,
:sections => default_sections }
end
|
.default_sections ⇒ Object
22
23
24
|
# File 'lib/exception_notifier/notifier.rb', line 22
def default_sections
%w(request session environment backtrace)
end
|
.default_sender_address ⇒ Object
10
11
12
|
# File 'lib/exception_notifier/notifier.rb', line 10
def default_sender_address
%("Exception Notifier" <[email protected]>)
end
|
Instance Method Details
#exception_notification(env, exception) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/exception_notifier/notifier.rb', line 39
def exception_notification(env, exception)
@env = env
@exception = exception
@options = (env['exception_notifier.options'] || {}).reverse_merge(self.class.default_options)
@kontroller = env['action_controller.instance'] || MissingController.new
@request = ActionDispatch::Request.new(env)
@backtrace = clean_backtrace(exception)
@sections = @options[:sections]
data = env['exception_notifier.exception_data'] || {}
data.each do |name, value|
instance_variable_set("@#{name}", value)
end
prefix = "#{@options[:email_prefix]}#{@kontroller.controller_name}##{@kontroller.action_name}"
subject = "#{prefix} (#{@exception.class}) #{@exception.message.inspect}"
mail(:to => @options[:exception_recipients], :from => @options[:sender_address], :subject => subject) do |format|
format.text { render "#{mailer_name}/exception_notification" }
end
end
|