summaryrefslogtreecommitdiff
path: root/vendor/plugins/exception_notification/lib/exception_notifier.rb
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/plugins/exception_notification/lib/exception_notifier.rb')
-rw-r--r--vendor/plugins/exception_notification/lib/exception_notifier.rb66
1 files changed, 0 insertions, 66 deletions
diff --git a/vendor/plugins/exception_notification/lib/exception_notifier.rb b/vendor/plugins/exception_notification/lib/exception_notifier.rb
deleted file mode 100644
index 72e2e1a..0000000
--- a/vendor/plugins/exception_notification/lib/exception_notifier.rb
+++ /dev/null
@@ -1,66 +0,0 @@
1require 'pathname'
2
3# Copyright (c) 2005 Jamis Buck
4#
5# Permission is hereby granted, free of charge, to any person obtaining
6# a copy of this software and associated documentation files (the
7# "Software"), to deal in the Software without restriction, including
8# without limitation the rights to use, copy, modify, merge, publish,
9# distribute, sublicense, and/or sell copies of the Software, and to
10# permit persons to whom the Software is furnished to do so, subject to
11# the following conditions:
12#
13# The above copyright notice and this permission notice shall be
14# included in all copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23class ExceptionNotifier < ActionMailer::Base
24 @@sender_address = %("Exception Notifier" <exception.notifier@default.com>)
25 cattr_accessor :sender_address
26
27 @@exception_recipients = []
28 cattr_accessor :exception_recipients
29
30 @@email_prefix = "[ERROR] "
31 cattr_accessor :email_prefix
32
33 @@sections = %w(request session environment backtrace)
34 cattr_accessor :sections
35
36 self.template_root = "#{File.dirname(__FILE__)}/../views"
37
38 def self.reloadable?() false end
39
40 def exception_notification(exception, controller, request, data={})
41 content_type "text/plain"
42
43 subject "#{email_prefix}#{controller.controller_name}##{controller.action_name} (#{exception.class}) #{exception.message.inspect}"
44
45 recipients exception_recipients
46 from sender_address
47
48 body data.merge({ :controller => controller, :request => request,
49 :exception => exception, :host => (request.env["HTTP_X_FORWARDED_HOST"] || request.env["HTTP_HOST"]),
50 :backtrace => sanitize_backtrace(exception.backtrace),
51 :rails_root => rails_root, :data => data,
52 :sections => sections })
53 end
54
55 private
56
57 def sanitize_backtrace(trace)
58 re = Regexp.new(/^#{Regexp.escape(rails_root)}/)
59 trace.map { |line| Pathname.new(line.gsub(re, "[RAILS_ROOT]")).cleanpath.to_s }
60 end
61
62 def rails_root
63 @rails_root ||= Pathname.new(RAILS_ROOT).cleanpath.to_s
64 end
65
66end