super_exception_notifier 2.0.8 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. data/{README.rdoc → README} +13 -17
  2. data/VERSION.yml +3 -3
  3. data/lib/exception_notification.rb +15 -0
  4. data/rails/init.rb +8 -12
  5. data/super_exception_notifier.gemspec +88 -0
  6. data/test/exception_notifier_helper_test.rb +2 -10
  7. data/test/exception_notifier_test.rb +2 -2
  8. data/test/exception_notify_functional_test.rb +6 -6
  9. data/test/mocks/controllers.rb +22 -15
  10. data/test/notifiable_test.rb +6 -6
  11. data/test/test_helper.rb +6 -4
  12. metadata +35 -33
  13. data/lib/exception_notifiable.rb +0 -177
  14. data/lib/exception_notifier.rb +0 -176
  15. data/lib/exception_notifier_helper.rb +0 -60
  16. data/lib/notifiable.rb +0 -92
  17. data/lib/super_exception_notifier/custom_exception_classes.rb +0 -16
  18. data/lib/super_exception_notifier/custom_exception_methods.rb +0 -50
  19. data/lib/super_exception_notifier/deprecated_methods.rb +0 -60
  20. data/lib/super_exception_notifier/git_blame.rb +0 -52
  21. data/lib/super_exception_notifier/helpful_hashes.rb +0 -66
  22. data/lib/super_exception_notifier/hooks_notifier.rb +0 -55
  23. data/lib/super_exception_notifier/notifiable_helper.rb +0 -80
  24. data/tasks/notified_task.rake +0 -15
  25. data/views/exception_notifier/_backtrace.html.erb +0 -1
  26. data/views/exception_notifier/_environment.html.erb +0 -14
  27. data/views/exception_notifier/_inspect_model.html.erb +0 -16
  28. data/views/exception_notifier/_request.html.erb +0 -8
  29. data/views/exception_notifier/_session.html.erb +0 -6
  30. data/views/exception_notifier/_title.html.erb +0 -3
  31. data/views/exception_notifier/background_exception_notification.text.plain.erb +0 -10
  32. data/views/exception_notifier/exception_notification.text.plain.erb +0 -15
  33. data/views/exception_notifier/rake_exception_notification.text.plain.erb +0 -6
data/test/test_helper.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'test/unit'
2
2
  require 'rubygems'
3
3
 
4
- require 'active_support'
5
- require 'actionmailer'
4
+ require 'rake'
5
+ require 'rake/tasklib'
6
+ require 'action_mailer'
6
7
  require 'active_record'
7
8
 
8
9
  #just requiring active record wasn't loading classes soon enough for SILENT_EXCEPTIONS
@@ -20,9 +21,10 @@ RAILS_ENV = 'test' unless defined?(RAILS_ENV)
20
21
  RAILS_DEFAULT_LOGGER = Logger.new(StringIO.new) unless defined?(RAILS_DEFAULT_LOGGER)
21
22
  #$:.unshift File.join(File.dirname(__FILE__), '../lib')
22
23
 
23
- require File.join(File.dirname(__FILE__), "..", "init")
24
+ #require File.join(File.dirname(__FILE__), "..", "init")
25
+ require "init"
24
26
 
25
- ExceptionNotifier.configure_exception_notifier do |config|
27
+ ExceptionNotification::Notifier.configure_exception_notifier do |config|
26
28
  # If left empty web hooks will not be engaged
27
29
  config[:web_hooks] = []
28
30
  config[:exception_recipients] = ["test.errors@example.com"]
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_exception_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ prerelease: false
5
+ segments:
6
+ - 3
7
+ - 0
8
+ - 1
9
+ version: 3.0.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Peter Boling
@@ -13,19 +18,33 @@ autorequire:
13
18
  bindir: bin
14
19
  cert_chain: []
15
20
 
16
- date: 2010-01-28 00:00:00 -05:00
21
+ date: 2010-05-13 00:00:00 -04:00
17
22
  default_executable:
18
23
  dependencies:
19
24
  - !ruby/object:Gem::Dependency
20
- name: actionmailer
25
+ name: action_mailer
26
+ prerelease: false
27
+ requirement: &id001 !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ segments:
32
+ - 0
33
+ version: "0"
21
34
  type: :runtime
22
- version_requirement:
23
- version_requirements: !ruby/object:Gem::Requirement
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
24
40
  requirements:
25
41
  - - ">="
26
42
  - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
27
45
  version: "0"
28
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
29
48
  description: |-
30
49
  Allows customization of:
31
50
  * Specify which level of notification you would like with an array of optional styles of notification (email, webhooks)
@@ -52,23 +71,13 @@ executables: []
52
71
  extensions: []
53
72
 
54
73
  extra_rdoc_files:
55
- - README.rdoc
74
+ - README
56
75
  files:
57
76
  - MIT-LICENSE
58
- - README.rdoc
77
+ - README
59
78
  - VERSION.yml
60
79
  - init.rb
61
- - lib/exception_notifiable.rb
62
- - lib/exception_notifier.rb
63
- - lib/exception_notifier_helper.rb
64
- - lib/notifiable.rb
65
- - lib/super_exception_notifier/custom_exception_classes.rb
66
- - lib/super_exception_notifier/custom_exception_methods.rb
67
- - lib/super_exception_notifier/deprecated_methods.rb
68
- - lib/super_exception_notifier/git_blame.rb
69
- - lib/super_exception_notifier/helpful_hashes.rb
70
- - lib/super_exception_notifier/hooks_notifier.rb
71
- - lib/super_exception_notifier/notifiable_helper.rb
80
+ - lib/exception_notification.rb
72
81
  - rails/app/views/exception_notifiable/400.html
73
82
  - rails/app/views/exception_notifiable/403.html
74
83
  - rails/app/views/exception_notifiable/404.html
@@ -82,18 +91,9 @@ files:
82
91
  - rails/app/views/exception_notifiable/503.html
83
92
  - rails/app/views/exception_notifiable/method_disabled.html.erb
84
93
  - rails/init.rb
85
- - tasks/notified_task.rake
86
- - views/exception_notifier/_backtrace.html.erb
87
- - views/exception_notifier/_environment.html.erb
88
- - views/exception_notifier/_inspect_model.html.erb
89
- - views/exception_notifier/_request.html.erb
90
- - views/exception_notifier/_session.html.erb
91
- - views/exception_notifier/_title.html.erb
92
- - views/exception_notifier/background_exception_notification.text.plain.erb
93
- - views/exception_notifier/exception_notification.text.plain.erb
94
- - views/exception_notifier/rake_exception_notification.text.plain.erb
94
+ - super_exception_notifier.gemspec
95
95
  has_rdoc: true
96
- homepage: http://github.com/pboling/exception_notification
96
+ homepage: http://github.com/pboling/exception_notifiable
97
97
  licenses: []
98
98
 
99
99
  post_install_message:
@@ -105,18 +105,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
+ segments:
109
+ - 0
108
110
  version: "0"
109
- version:
110
111
  required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  requirements:
112
113
  - - ">="
113
114
  - !ruby/object:Gem::Version
115
+ segments:
116
+ - 0
114
117
  version: "0"
115
- version:
116
118
  requirements: []
117
119
 
118
120
  rubyforge_project:
119
- rubygems_version: 1.3.5
121
+ rubygems_version: 1.3.6
120
122
  signing_key:
121
123
  specification_version: 3
122
124
  summary: Allows unhandled (and handled!) exceptions to be captured and sent via email
@@ -1,177 +0,0 @@
1
- require 'ipaddr'
2
-
3
- module ExceptionNotifiable
4
- include SuperExceptionNotifier::NotifiableHelper
5
-
6
- def self.included(base)
7
- base.extend ClassMethods
8
-
9
- # Adds the following class attributes to the classes that include ExceptionNotifiable
10
- # HTTP status codes and what their 'English' status message is
11
- base.cattr_accessor :http_status_codes
12
- base.http_status_codes = HTTP_STATUS_CODES
13
- # error_layout:
14
- # can be defined at controller level to the name of the desired error layout,
15
- # or set to true to render the controller's own default layout,
16
- # or set to false to render errors with no layout
17
- base.cattr_accessor :error_layout
18
- base.error_layout = nil
19
- # Rails error classes to rescue and how to rescue them (which error code to use)
20
- base.cattr_accessor :error_class_status_codes
21
- base.error_class_status_codes = self.codes_for_error_classes
22
- # Verbosity of the gem
23
- base.cattr_accessor :exception_notifiable_verbose
24
- base.exception_notifiable_verbose = false
25
- # Do Not Ever send error notification emails for these Error Classes
26
- base.cattr_accessor :exception_notifiable_silent_exceptions
27
- base.exception_notifiable_silent_exceptions = SILENT_EXCEPTIONS
28
- # Notification Level
29
- base.cattr_accessor :exception_notifiable_notification_level
30
- base.exception_notifiable_notification_level = [:render, :email, :web_hooks]
31
- end
32
-
33
- module ClassMethods
34
- include SuperExceptionNotifier::DeprecatedMethods
35
-
36
- # specifies ip addresses that should be handled as though local
37
- def consider_local(*args)
38
- local_addresses.concat(args.flatten.map { |a| IPAddr.new(a) })
39
- end
40
-
41
- def local_addresses
42
- addresses = read_inheritable_attribute(:local_addresses)
43
- unless addresses
44
- addresses = [IPAddr.new("127.0.0.1")]
45
- write_inheritable_attribute(:local_addresses, addresses)
46
- end
47
- addresses
48
- end
49
-
50
- # set the exception_data deliverer OR retrieve the exception_data
51
- def exception_data(deliverer = nil)
52
- if deliverer
53
- write_inheritable_attribute(:exception_data, deliverer)
54
- else
55
- read_inheritable_attribute(:exception_data)
56
- end
57
- end
58
-
59
- def be_silent_for_exception?(exception)
60
- self.exception_notifiable_silent_exceptions.respond_to?(:any?) && self.exception_notifiable_silent_exceptions.any? {|klass| klass === exception }
61
- end
62
-
63
- end
64
-
65
- def be_silent_for_exception?(exception)
66
- self.class.be_silent_for_exception?(exception)
67
- end
68
-
69
-
70
- private
71
-
72
- def notification_level_sends_email?
73
- self.class.exception_notifiable_notification_level.include?(:email)
74
- end
75
-
76
- def notification_level_sends_web_hooks?
77
- self.class.exception_notifiable_notification_level.include?(:web_hooks)
78
- end
79
-
80
- def notification_level_renders?
81
- self.class.exception_notifiable_notification_level.include?(:render)
82
- end
83
-
84
- # overrides Rails' local_request? method to also check any ip
85
- # addresses specified through consider_local.
86
- def local_request?
87
- remote = IPAddr.new(request.remote_ip)
88
- !self.class.local_addresses.detect { |addr| addr.include?(remote) }.nil?
89
- end
90
-
91
- # When the action being executed has its own local error handling (rescue)
92
- # Or when the error accurs somewhere without a subsequent render (eg. method calls in console)
93
- def rescue_with_handler(exception)
94
- to_return = super
95
- if to_return
96
- verbose = self.class.exception_notifiable_verbose
97
- puts "[RESCUE STYLE] rescue_with_handler" if verbose
98
- data = get_exception_data
99
- status_code = status_code_for_exception(exception)
100
- #We only send email if it has been configured in environment
101
- send_email = should_email_on_exception?(exception, status_code, verbose)
102
- #We only send web hooks if they've been configured in environment
103
- send_web_hooks = should_web_hook_on_exception?(exception, status_code, verbose)
104
- the_blamed = ExceptionNotifier.config[:git_repo_path].nil? ? nil : lay_blame(exception)
105
- rejected_sections = %w(request session)
106
- # Debugging output
107
- verbose_output(exception, status_code, "rescued by handler", send_email, send_web_hooks, nil, the_blamed, rejected_sections) if verbose
108
- # Send the exception notification email
109
- perform_exception_notify_mailing(exception, data, nil, the_blamed, verbose, rejected_sections) if send_email
110
- # Send Web Hook requests
111
- HooksNotifier.deliver_exception_to_web_hooks(ExceptionNotifier.config, exception, self, request, data, the_blamed) if send_web_hooks
112
- end
113
- to_return
114
- end
115
-
116
- # When the action being executed is letting SEN handle the exception completely
117
- def rescue_action_in_public(exception)
118
- # If the error class is NOT listed in the rails_errror_class hash then we get a generic 500 error:
119
- # OTW if the error class is listed, but has a blank code or the code is == '200' then we get a custom error layout rendered
120
- # OTW the error class is listed!
121
- verbose = self.class.exception_notifiable_verbose
122
- puts "[RESCUE STYLE] rescue_action_in_public" if verbose
123
- status_code = status_code_for_exception(exception)
124
- if status_code == '200'
125
- notify_and_render_error_template(status_code, request, exception, ExceptionNotifier.get_view_path_for_class(exception, verbose), verbose)
126
- else
127
- notify_and_render_error_template(status_code, request, exception, ExceptionNotifier.get_view_path_for_status_code(status_code, verbose), verbose)
128
- end
129
- end
130
-
131
- def notify_and_render_error_template(status_cd, request, exception, file_path, verbose = false)
132
- status = self.class.http_status_codes[status_cd] ? status_cd + " " + self.class.http_status_codes[status_cd] : status_cd
133
- data = get_exception_data
134
- #We only send email if it has been configured in environment
135
- send_email = should_email_on_exception?(exception, status_cd, verbose)
136
- #We only send web hooks if they've been configured in environment
137
- send_web_hooks = should_web_hook_on_exception?(exception, status_cd, verbose)
138
- the_blamed = ExceptionNotifier.config[:git_repo_path].nil? ? nil : lay_blame(exception)
139
- rejected_sections = request.nil? ? %w(request session) : []
140
- # Debugging output
141
- verbose_output(exception, status_cd, file_path, send_email, send_web_hooks, request, the_blamed, rejected_sections) if verbose
142
- #TODO: is _rescue_action something from rails 3?
143
- #if !(self.controller_name == 'application' && self.action_name == '_rescue_action')
144
- # Send the exception notification email
145
- perform_exception_notify_mailing(exception, data, request, the_blamed, verbose, rejected_sections) if send_email
146
- # Send Web Hook requests
147
- HooksNotifier.deliver_exception_to_web_hooks(ExceptionNotifier.config, exception, self, request, data, the_blamed) if send_web_hooks
148
-
149
- # We put the render call after the deliver call to ensure that, if the
150
- # deliver raises an exception, we don't call render twice.
151
- # Render the error page to the end user
152
- render_error_template(file_path, status)
153
- end
154
-
155
- def is_local?
156
- (consider_all_requests_local || local_request?)
157
- end
158
-
159
- def status_code_for_exception(exception)
160
- self.class.error_class_status_codes[exception.class].nil? ?
161
- '500' :
162
- self.class.error_class_status_codes[exception.class].blank? ?
163
- '200' :
164
- self.class.error_class_status_codes[exception.class]
165
- end
166
-
167
- def render_error_template(file, status)
168
- respond_to do |type|
169
- type.html { render :file => file,
170
- :layout => self.class.error_layout,
171
- :status => status }
172
- type.all { render :nothing => true,
173
- :status => status}
174
- end
175
- end
176
-
177
- end
@@ -1,176 +0,0 @@
1
- require 'pathname'
2
-
3
- class ExceptionNotifier < ActionMailer::Base
4
-
5
- #andrewroth reported that @@config gets clobbered because rails loads this class twice when installed as a plugin, and adding the ||= fixed it.
6
- @@config ||= {
7
- # If left empty web hooks will not be engaged
8
- :web_hooks => [],
9
- :app_name => "[MYAPP]",
10
- :version => "0.0.0",
11
- :sender_address => "super.exception.notifier@example.com",
12
- :exception_recipients => [],
13
- # Customize the subject line
14
- :subject_prepend => "[#{(defined?(Rails) ? Rails.env : RAILS_ENV).capitalize} ERROR] ",
15
- :subject_append => nil,
16
- # Include which sections of the exception email?
17
- :sections => %w(request session environment backtrace),
18
- :skip_local_notification => true,
19
- :view_path => nil,
20
- #Error Notification will be sent if the HTTP response code for the error matches one of the following error codes
21
- :notify_error_codes => %W( 405 500 503 ),
22
- #Error Notification will be sent if the error class matches one of the following error error classes
23
- :notify_error_classes => %W( ),
24
- :notify_other_errors => true,
25
- :git_repo_path => nil,
26
- :template_root => "#{File.dirname(__FILE__)}/../views"
27
- }
28
-
29
- cattr_accessor :config
30
-
31
- def self.configure_exception_notifier(&block)
32
- yield @@config
33
- end
34
-
35
- self.template_root = config[:template_root]
36
-
37
- def self.reloadable?() false end
38
-
39
- # Returns an array of potential filenames to look for
40
- # eg. For the Exception Class - SuperExceptionNotifier::CustomExceptionClasses::MethodDisabled
41
- # the filename handles are:
42
- # super_exception_notifier_custom_exception_classes_method_disabled
43
- # method_disabled
44
- def self.exception_to_filenames(exception)
45
- filenames = []
46
- e = exception.to_s
47
- filenames << ExceptionNotifier.filenamify(e)
48
-
49
- last_colon = e.rindex(':')
50
- unless last_colon.nil?
51
- filenames << ExceptionNotifier.filenamify(e[(last_colon + 1)..(e.length - 1)])
52
- end
53
- filenames
54
- end
55
-
56
- def self.sections_for_email(rejected_sections, request)
57
- rejected_sections = rejected_sections.nil? ? request.nil? ? %w(request session) : [] : rejected_sections
58
- rejected_sections.empty? ? config[:sections] : config[:sections].reject{|s| rejected_sections.include?(s) }
59
- end
60
-
61
- # Converts Stringified Class Names to acceptable filename handles with underscores
62
- def self.filenamify(str)
63
- str.delete(':').gsub( /([A-Za-z])([A-Z])/, '\1' << '_' << '\2').downcase
64
- end
65
-
66
- # What is the path of the file we will render to the user based on a given status code?
67
- def self.get_view_path_for_status_code(status_cd, verbose = false)
68
- file_name = ExceptionNotifier.get_view_path(status_cd, verbose)
69
- #ExceptionNotifierHelper::COMPAT_MODE ? "#{File.dirname(__FILE__)}/../rails/app/views/exception_notifiable/500.html" : "500.html"
70
- file_name.nil? ? self.catch_all(verbose) : file_name
71
- end
72
-
73
- # def self.get_view_path_for_files(filenames = [])
74
- # filepaths = filenames.map do |file|
75
- # ExceptionNotifier.get_view_path(file)
76
- # end.compact
77
- # filepaths.empty? ? "#{File.dirname(__FILE__)}/../rails/app/views/exception_notifiable/500.html" : filepaths.first
78
- # end
79
-
80
- # What is the path of the file we will render to the user based on a given exception class?
81
- def self.get_view_path_for_class(exception, verbose = false)
82
- return self.catch_all(verbose) if exception.nil?
83
- #return self.catch_all(verbose) unless exception.is_a?(StandardError) || exception.is_a?(Class) # For some reason exception.is_a?(Class) works in console, but not when running in mongrel (ALWAYS returns false)?!?!?
84
- filepaths = ExceptionNotifier.exception_to_filenames(exception).map do |file|
85
- ExceptionNotifier.get_view_path(file, verbose)
86
- end.compact
87
- filepaths.empty? ? self.catch_all(verbose) : filepaths.first
88
- end
89
-
90
- def self.catch_all(verbose = false)
91
- puts "[CATCH ALL INVOKED] #{File.dirname(__FILE__)}/../rails/app/views/exception_notifiable/500.html" if verbose
92
- "#{File.dirname(__FILE__)}/../rails/app/views/exception_notifiable/500.html"
93
- end
94
-
95
- # Check the usual suspects
96
- def self.get_view_path(file_name, verbose = false)
97
- if File.exist?("#{RAILS_ROOT}/public/#{file_name}.html")
98
- puts "[FOUND FILE:A] #{RAILS_ROOT}/public/#{file_name}.html" if verbose
99
- "#{RAILS_ROOT}/public/#{file_name}.html"
100
- elsif !config[:view_path].nil? && File.exist?("#{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html.erb")
101
- puts "[FOUND FILE:B] #{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html.erb" if verbose
102
- "#{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html.erb"
103
- elsif !config[:view_path].nil? && File.exist?("#{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html")
104
- puts "[FOUND FILE:C] #{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html" if verbose
105
- "#{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html"
106
- elsif File.exist?("#{File.dirname(__FILE__)}/../rails/app/views/exception_notifiable/#{file_name}.html.erb")
107
- puts "[FOUND FILE:D] #{File.dirname(__FILE__)}/../rails/app/views/exception_notifiable/#{file_name}.html.erb" if verbose
108
- "#{File.dirname(__FILE__)}/../rails/app/views/exception_notifiable/#{file_name}.html.erb"
109
- elsif File.exist?("#{File.dirname(__FILE__)}/../rails/app/views/exception_notifiable/#{file_name}.html")
110
- #ExceptionNotifierHelper::COMPAT_MODE ? "#{File.dirname(__FILE__)}/../rails/app/views/exception_notifiable/#{file_name}.html" : "#{status_cd}.html"
111
- puts "[FOUND FILE:E] #{File.dirname(__FILE__)}/../rails/app/views/exception_notifiable/#{file_name}.html" if verbose
112
- "#{File.dirname(__FILE__)}/../rails/app/views/exception_notifiable/#{file_name}.html"
113
- else
114
- nil
115
- end
116
- end
117
-
118
- def exception_notification(exception, class_name = nil, method_name = nil, request = nil, data = {}, the_blamed = nil, rejected_sections = nil)
119
- body_hash = error_environment_data_hash(exception, class_name, method_name, request, data, the_blamed, rejected_sections)
120
- #Prefer to have custom, potentially HTML email templates available
121
- #content_type "text/plain"
122
- recipients config[:exception_recipients]
123
- from config[:sender_address]
124
-
125
- request.session.inspect unless request.nil? # Ensure session data is loaded (Rails 2.3 lazy-loading)
126
-
127
- subject "#{config[:subject_prepend]}#{body_hash[:location]} (#{exception.class}) #{exception.message.inspect}#{config[:subject_append]}"
128
- body body_hash
129
- end
130
-
131
- def background_exception_notification(exception, data = {}, the_blamed = nil, rejected_sections = %w(request session))
132
- exception_notification(exception, nil, nil, nil, data, the_blamed, rejected_sections)
133
- end
134
-
135
- def rake_exception_notification(exception, task, data={}, the_blamed = nil, rejected_sections = %w(request session))
136
- exception_notification(exception, "", "#{task.name}", nil, data, the_blamed, rejected_sections)
137
- end
138
-
139
- private
140
-
141
- def error_environment_data_hash(exception, class_name = nil, method_name = nil, request = nil, data = {}, the_blamed = nil, rejected_sections = nil)
142
- data.merge!({
143
- :exception => exception,
144
- :backtrace => sanitize_backtrace(exception.backtrace),
145
- :rails_root => rails_root,
146
- :data => data,
147
- :the_blamed => the_blamed
148
- })
149
-
150
- data.merge!({:class_name => class_name}) if class_name
151
- data.merge!({:method_name => method_name}) if method_name
152
- if class_name && method_name
153
- data.merge!({:location => "#{class_name}##{method_name}"})
154
- elsif method_name
155
- data.merge!({:location => "#{method_name}"})
156
- else
157
- data.merge!({:location => sanitize_backtrace([exception.backtrace.first]).first})
158
- end
159
- if request
160
- data.merge!({:request => request})
161
- data.merge!({:host => (request.env['HTTP_X_REAL_IP'] || request.env["HTTP_X_FORWARDED_HOST"] || request.env["HTTP_HOST"])})
162
- end
163
- data.merge!({:sections => ExceptionNotifier.sections_for_email(rejected_sections, request)})
164
- return data
165
- end
166
-
167
- def sanitize_backtrace(trace)
168
- re = Regexp.new(/^#{Regexp.escape(rails_root)}/)
169
- trace.map { |line| Pathname.new(line.gsub(re, "[RAILS_ROOT]")).cleanpath.to_s }
170
- end
171
-
172
- def rails_root
173
- @rails_root ||= Pathname.new(RAILS_ROOT).cleanpath.to_s
174
- end
175
-
176
- end