super_exception_notifier 2.0.8 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.rdoc → README} +13 -17
- data/VERSION.yml +3 -3
- data/lib/exception_notification.rb +15 -0
- data/rails/init.rb +8 -12
- data/super_exception_notifier.gemspec +88 -0
- data/test/exception_notifier_helper_test.rb +2 -10
- data/test/exception_notifier_test.rb +2 -2
- data/test/exception_notify_functional_test.rb +6 -6
- data/test/mocks/controllers.rb +22 -15
- data/test/notifiable_test.rb +6 -6
- data/test/test_helper.rb +6 -4
- metadata +35 -33
- data/lib/exception_notifiable.rb +0 -177
- data/lib/exception_notifier.rb +0 -176
- data/lib/exception_notifier_helper.rb +0 -60
- data/lib/notifiable.rb +0 -92
- data/lib/super_exception_notifier/custom_exception_classes.rb +0 -16
- data/lib/super_exception_notifier/custom_exception_methods.rb +0 -50
- data/lib/super_exception_notifier/deprecated_methods.rb +0 -60
- data/lib/super_exception_notifier/git_blame.rb +0 -52
- data/lib/super_exception_notifier/helpful_hashes.rb +0 -66
- data/lib/super_exception_notifier/hooks_notifier.rb +0 -55
- data/lib/super_exception_notifier/notifiable_helper.rb +0 -80
- data/tasks/notified_task.rake +0 -15
- data/views/exception_notifier/_backtrace.html.erb +0 -1
- data/views/exception_notifier/_environment.html.erb +0 -14
- data/views/exception_notifier/_inspect_model.html.erb +0 -16
- data/views/exception_notifier/_request.html.erb +0 -8
- data/views/exception_notifier/_session.html.erb +0 -6
- data/views/exception_notifier/_title.html.erb +0 -3
- data/views/exception_notifier/background_exception_notification.text.plain.erb +0 -10
- data/views/exception_notifier/exception_notification.text.plain.erb +0 -15
- data/views/exception_notifier/rake_exception_notification.text.plain.erb +0 -6
@@ -1,80 +0,0 @@
|
|
1
|
-
#Copyright (c) 2008-2009 Peter H. Boling of 9thBit LLC
|
2
|
-
#Released under the MIT license
|
3
|
-
|
4
|
-
module SuperExceptionNotifier
|
5
|
-
module NotifiableHelper
|
6
|
-
include CustomExceptionClasses
|
7
|
-
include CustomExceptionMethods
|
8
|
-
include HelpfulHashes
|
9
|
-
include GitBlame
|
10
|
-
include HooksNotifier
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def get_method_name
|
15
|
-
if /`(.*)'/.match(caller.first)
|
16
|
-
return $1
|
17
|
-
end
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def get_exception_data
|
22
|
-
deliverer = self.class.exception_data
|
23
|
-
return case deliverer
|
24
|
-
when nil then {}
|
25
|
-
when Symbol then send(deliverer)
|
26
|
-
when Proc then deliverer.call(self)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def verbose_output(exception, status_cd, file_path, send_email, send_web_hooks, request = nil, the_blamed = nil, rejected_sections = nil)
|
31
|
-
puts "[EXCEPTION] #{exception}"
|
32
|
-
puts "[EXCEPTION CLASS] #{exception.class}"
|
33
|
-
puts "[EXCEPTION STATUS_CD] #{status_cd}"
|
34
|
-
puts "[ERROR LAYOUT] #{self.class.error_layout}" if self.class.respond_to?(:error_layout)
|
35
|
-
puts "[ERROR VIEW PATH] #{ExceptionNotifier.config[:view_path]}" if !ExceptionNotifier.nil? && !ExceptionNotifier.config[:view_path].nil?
|
36
|
-
puts "[ERROR FILE PATH] #{file_path.inspect}"
|
37
|
-
puts "[ERROR EMAIL] #{send_email ? "YES" : "NO"}"
|
38
|
-
puts "[ERROR WEB HOOKS] #{send_web_hooks ? "YES" : "NO"}"
|
39
|
-
puts "[COMPAT MODE] #{ExceptionNotifierHelper::COMPAT_MODE ? "YES" : "NO"}"
|
40
|
-
puts "[THE BLAMED] #{the_blamed}"
|
41
|
-
puts "[SECTIONS] #{ExceptionNotifier.sections_for_email(rejected_sections, request)}"
|
42
|
-
req = request ? " for request_uri=#{request.request_uri} and env=#{request.env.inspect}" : ""
|
43
|
-
logger.error("render_error(#{status_cd}, #{self.class.http_status_codes[status_cd]}) invoked#{req}") if self.class.respond_to?(:http_status_codes) && !logger.nil?
|
44
|
-
end
|
45
|
-
|
46
|
-
def perform_exception_notify_mailing(exception, data, request = nil, the_blamed = nil, verbose = false, rejected_sections = nil)
|
47
|
-
if ExceptionNotifier.config[:exception_recipients].blank?
|
48
|
-
puts "[EMAIL NOTIFICATION] ExceptionNotifier.config[:exception_recipients] is blank, notification cancelled!" if verbose
|
49
|
-
else
|
50
|
-
class_name = self.respond_to?(:controller_name) ? self.controller_name : self.to_s
|
51
|
-
method_name = self.respond_to?(:action_name) ? self.action_name : get_method_name
|
52
|
-
ExceptionNotifier.deliver_exception_notification(exception, class_name, method_name,
|
53
|
-
request, data, the_blamed, rejected_sections)
|
54
|
-
puts "[EMAIL NOTIFICATION] Sent" if verbose
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def should_email_on_exception?(exception, status_cd = nil, verbose = false)
|
59
|
-
notification_level_sends_email? && !ExceptionNotifier.config[:exception_recipients].blank? && should_notify_on_exception?(exception, status_cd, verbose)
|
60
|
-
end
|
61
|
-
|
62
|
-
def should_web_hook_on_exception?(exception, status_cd = nil, verbose = false)
|
63
|
-
notification_level_sends_web_hooks? && !ExceptionNotifier.config[:web_hooks].blank? && should_notify_on_exception?(exception, status_cd, verbose)
|
64
|
-
end
|
65
|
-
|
66
|
-
# Relies on the base class to define be_silent_for_exception?
|
67
|
-
def should_notify_on_exception?(exception, status_cd = nil, verbose = false)
|
68
|
-
# don't notify (email or web hooks) on exceptions raised locally
|
69
|
-
verbose && ExceptionNotifier.config[:skip_local_notification] && is_local? ?
|
70
|
-
"[NOTIFY LOCALLY] NO" :
|
71
|
-
nil
|
72
|
-
return false if ExceptionNotifier.config[:skip_local_notification] && is_local?
|
73
|
-
# don't notify (email or web hooks) exceptions raised that match ExceptionNotifiable.notifiable_silent_exceptions
|
74
|
-
return false if self.be_silent_for_exception?(exception)
|
75
|
-
return true if ExceptionNotifier.config[:notify_error_classes].include?(exception.class)
|
76
|
-
return true if !status_cd.nil? && ExceptionNotifier.config[:notify_error_codes].include?(status_cd)
|
77
|
-
return ExceptionNotifier.config[:notify_other_errors]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
data/tasks/notified_task.rake
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<%= @backtrace.join "\n" %>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<% if @request -%>
|
2
|
-
<% max = @request.env.keys.max { |a,b| a.length <=> b.length } -%>
|
3
|
-
<% @request.env.keys.sort.each do |key| -%>
|
4
|
-
* <%= "%-*s: %s" % [max.length, key, filter_sensitive_post_data_from_env(key, @request.env[key].to_s.strip)] %>
|
5
|
-
<% end -%>
|
6
|
-
<% end -%>
|
7
|
-
<% if @data -%>
|
8
|
-
<% @data.each do |key, value| -%>
|
9
|
-
* <%= key %>: <%= value %>
|
10
|
-
<% end -%>
|
11
|
-
<% end -%>
|
12
|
-
|
13
|
-
* Process: <%= $$ %>
|
14
|
-
* Server : <%= `hostname -s`.chomp %>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<% if show_attributes -%>
|
2
|
-
[attributes]
|
3
|
-
<% attrs = inspect_model.attributes -%>
|
4
|
-
<% max = attrs.keys.max { |a,b| a.length <=> b.length } -%>
|
5
|
-
<% attrs.keys.sort.each do |attr| -%>
|
6
|
-
* <%= "%*-s: %s" % [max.length, attr, object_to_yaml(attrs[attr]).gsub(/\n/, "\n ").strip] %>
|
7
|
-
<% end -%>
|
8
|
-
<% end -%>
|
9
|
-
|
10
|
-
<% if show_instance_variables -%>
|
11
|
-
[instance variables]
|
12
|
-
<% inspect_model.instance_variables.sort.each do |variable| -%>
|
13
|
-
<%- next if variable == "@attributes" -%>
|
14
|
-
* <%= variable %>: <%= inspect_value(inspect_model.instance_variable_get(variable)) %>
|
15
|
-
<% end -%>
|
16
|
-
<% end -%>
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<% if @request -%>
|
2
|
-
* URL : <%= @request.protocol %><%= @host %><%= @request.request_uri %>
|
3
|
-
* Method : <%= @request.method.to_s.upcase %>
|
4
|
-
* IP address: <%= @request.env['HTTP_X_REAL_IP'] ||@request.env["HTTP_X_FORWARDED_FOR"] || @request.env["REMOTE_ADDR"] %>
|
5
|
-
* Parameters: <%= filter_sensitive_post_data_parameters(@request.parameters).inspect %>
|
6
|
-
<% end -%>
|
7
|
-
* Rails root: <%= @rails_root %>
|
8
|
-
|
@@ -1,6 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
@request.session.instance_variable_set(:@session_id, @request.session_options[:id]) if @request.session.instance_variable_get(:@session_id).nil?
|
3
|
-
@request.session.instance_variable_set(:@data, @request.session.to_hash) if @request.session.instance_variable_get(:@data).nil?
|
4
|
-
%>
|
5
|
-
* session id: <%= @request.session.instance_variable_get(:@session_id).inspect %>
|
6
|
-
* data: <%= PP.pp(@request.session.instance_variable_get(:@data),"").gsub(/\n/, "\n ").strip %>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
A <%= @exception.class %> occurred in <%= @controller_name %>#<%= @controller_action_name %>:
|
2
|
-
|
3
|
-
<%= @exception.message %>
|
4
|
-
<%= @backtrace.first %>
|
5
|
-
|
6
|
-
<% if @data[:info] -%>
|
7
|
-
<%=@data[:info].to_yaml%>
|
8
|
-
<% end -%>
|
9
|
-
|
10
|
-
<%= @sections.map { |section| render_section(section) }.join %>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<% unless @request.nil? -%>
|
2
|
-
<%= @request.protocol %><%= @host %><%= @request.request_uri %>
|
3
|
-
<% end -%>
|
4
|
-
A <%= @exception.class %> occurred in <%= @location %>:
|
5
|
-
<%= @exception.message %>
|
6
|
-
<%= @backtrace.first %>
|
7
|
-
|
8
|
-
<% if @data[:info] -%>
|
9
|
-
<%=@data[:info].to_yaml%>
|
10
|
-
<% end -%>
|
11
|
-
|
12
|
-
<% unless @the_blamed.nil? || @the_blamed[:author].nil? %>
|
13
|
-
Git Blame: '<%=@the_blamed[:author]%>' last modified line #<%=@the_blamed[:line]%> in <%=@the_blamed[:file]%>
|
14
|
-
<% end%>
|
15
|
-
<%= @sections.map { |section| render_section(section) }.join %>
|