exception_notification_rails3 1.0.0 → 1.2.0
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.
data/README
CHANGED
@@ -64,6 +64,39 @@ existing sections defined by the plugin for examples of how to write your own.
|
|
64
64
|
After an exception notification has been delivered the rack environment variable
|
65
65
|
'exception_notifier.delivered' will be set to +true+.
|
66
66
|
|
67
|
+
== Notification in backround processes outside of the request/response
|
68
|
+
|
69
|
+
Using:
|
70
|
+
|
71
|
+
ExceptionNotifier.with do
|
72
|
+
some code...
|
73
|
+
end
|
74
|
+
|
75
|
+
ExceptionNotifier.with({
|
76
|
+
:name => 'MyDaemon',
|
77
|
+
:data => { :username => "david" },
|
78
|
+
:files => [ "path/to/screenshot.png" ]
|
79
|
+
}) do
|
80
|
+
some code...
|
81
|
+
end
|
82
|
+
|
83
|
+
begin
|
84
|
+
some code...
|
85
|
+
rescue => e
|
86
|
+
ExceptionNotifier::Notifier.background_exception_notification(e).deliver
|
87
|
+
end
|
88
|
+
|
89
|
+
begin
|
90
|
+
some code...
|
91
|
+
rescue => e
|
92
|
+
screenshot_file = make_screenshot!
|
93
|
+
|
94
|
+
ExceptionNotifier::Notifier.background_exception_notification(e, {
|
95
|
+
:name => "MyDaemon",
|
96
|
+
:files => [ screenshot_file ]
|
97
|
+
}).deliver
|
98
|
+
end
|
99
|
+
|
67
100
|
== Rails 2.3 stable and earlier
|
68
101
|
|
69
102
|
If you are running Rails 2.3 then see the branch for that:
|
@@ -78,4 +111,4 @@ If you are running pre-rack Rails then see this tag:
|
|
78
111
|
|
79
112
|
https://rails.lighthouseapp.com/projects/8995-rails-plugins
|
80
113
|
|
81
|
-
Copyright (c) 2005 Jamis Buck, released under the MIT license
|
114
|
+
Copyright (c) 2005 Jamis Buck, released under the MIT license
|
@@ -57,6 +57,27 @@ class ExceptionNotifier
|
|
57
57
|
format.text { render "#{mailer_name}/exception_notification" }
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
def background_exception_notification(exception, options = {})
|
62
|
+
@exception = exception
|
63
|
+
@options = ExceptionNotifier.background_options.reverse_merge(self.class.default_options)
|
64
|
+
@kontroller = MissingController.new
|
65
|
+
@backtrace = clean_backtrace(exception)
|
66
|
+
@sections = %w(data backtrace)
|
67
|
+
|
68
|
+
prefix = "#{@options[:email_prefix]}#{options[:name] || '[background]'}"
|
69
|
+
subject = "#{prefix} (#{@exception.class}) #{@exception.message.inspect}"
|
70
|
+
|
71
|
+
(options[:files] || []).each do |path|
|
72
|
+
attachments[File.basename(path)] = File.read(path)
|
73
|
+
end
|
74
|
+
|
75
|
+
@data = options[:data] || {}
|
76
|
+
|
77
|
+
mail(:to => @options[:exception_recipients], :from => @options[:sender_address], :subject => subject) do |format|
|
78
|
+
format.text { render "#{mailer_name}/exception_notification", :layout => false }
|
79
|
+
end
|
80
|
+
end
|
60
81
|
|
61
82
|
private
|
62
83
|
|
data/lib/exception_notifier.rb
CHANGED
@@ -2,11 +2,26 @@ require 'action_dispatch'
|
|
2
2
|
require 'exception_notifier/notifier'
|
3
3
|
|
4
4
|
class ExceptionNotifier
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
class << self
|
6
|
+
def default_ignore_exceptions
|
7
|
+
[].tap do |exceptions|
|
8
|
+
exceptions << ActiveRecord::RecordNotFound if defined? ActiveRecord
|
9
|
+
exceptions << AbstractController::ActionNotFound if defined? AbstractController
|
10
|
+
exceptions << ActionController::RoutingError if defined? ActionController
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def background_options
|
15
|
+
@background_options ||= Rails.application.middleware.find { |klass| klass == ExceptionNotifier }.args.first rescue {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def with(options = {}, &block)
|
19
|
+
block.call
|
20
|
+
rescue Exception => exception
|
21
|
+
unless Array.wrap(background_options[:ignore_exceptions]).include?(exception.class)
|
22
|
+
Notifier.background_exception_notification(exception, options).deliver
|
23
|
+
end
|
24
|
+
raise exception
|
10
25
|
end
|
11
26
|
end
|
12
27
|
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_notification_rails3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 23
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.0
|
9
|
+
version: 1.2.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Jamis Buck
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-
|
18
|
+
date: 2010-11-04 00:00:00 +02:00
|
20
19
|
default_executable:
|
21
20
|
dependencies: []
|
22
21
|
|
@@ -34,6 +33,7 @@ files:
|
|
34
33
|
- lib/exception_notifier/views/exception_notifier/_environment.text.erb
|
35
34
|
- lib/exception_notifier/views/exception_notifier/exception_notification.text.erb
|
36
35
|
- lib/exception_notifier/views/exception_notifier/_session.text.erb
|
36
|
+
- lib/exception_notifier/views/exception_notifier/_data.text.erb
|
37
37
|
- lib/exception_notifier/views/exception_notifier/_request.text.erb
|
38
38
|
- lib/exception_notifier/views/exception_notifier/_title.text.erb
|
39
39
|
- lib/exception_notifier/notifier.rb
|
@@ -52,7 +52,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
52
|
requirements:
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
hash: 3
|
56
55
|
segments:
|
57
56
|
- 0
|
58
57
|
version: "0"
|
@@ -61,7 +60,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
60
|
requirements:
|
62
61
|
- - ">="
|
63
62
|
- !ruby/object:Gem::Version
|
64
|
-
hash: 3
|
65
63
|
segments:
|
66
64
|
- 0
|
67
65
|
version: "0"
|
@@ -71,6 +69,6 @@ rubyforge_project:
|
|
71
69
|
rubygems_version: 1.3.7
|
72
70
|
signing_key:
|
73
71
|
specification_version: 3
|
74
|
-
summary: Exception notification by email for Rails apps
|
72
|
+
summary: Exception notification by email for Rails 3 apps
|
75
73
|
test_files: []
|
76
74
|
|