exception_notification_rails3 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -64,6 +64,14 @@ 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
+
67
75
  == Rails 2.3 stable and earlier
68
76
 
69
77
  If you are running Rails 2.3 then see the branch for that:
@@ -57,6 +57,20 @@ class ExceptionNotifier
57
57
  format.text { render "#{mailer_name}/exception_notification" }
58
58
  end
59
59
  end
60
+
61
+ def background_exception_notification(exception)
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(backtrace)
67
+
68
+ subject = "#{@options[:email_prefix]} (#{@exception.class}) #{@exception.message.inspect}"
69
+
70
+ mail(:to => @options[:exception_recipients], :from => @options[:sender_address], :subject => subject) do |format|
71
+ format.text { render "#{mailer_name}/exception_notification" }
72
+ end
73
+ end
60
74
 
61
75
  private
62
76
 
@@ -2,11 +2,26 @@ require 'action_dispatch'
2
2
  require 'exception_notifier/notifier'
3
3
 
4
4
  class ExceptionNotifier
5
- def self.default_ignore_exceptions
6
- [].tap do |exceptions|
7
- exceptions << ActiveRecord::RecordNotFound if defined? ActiveRecord
8
- exceptions << AbstractController::ActionNotFound if defined? AbstractController
9
- exceptions << ActionController::RoutingError if defined? ActionController
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(&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).deliver
23
+ end
24
+ raise exception
10
25
  end
11
26
  end
12
27
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_notification_rails3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jamis Buck
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-03-13 00:00:00 +02:00
19
+ date: 2010-10-19 00:00:00 +03:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -30,13 +30,13 @@ extra_rdoc_files: []
30
30
 
31
31
  files:
32
32
  - README
33
+ - lib/exception_notifier/notifier.rb
33
34
  - lib/exception_notifier/views/exception_notifier/_backtrace.text.erb
34
35
  - lib/exception_notifier/views/exception_notifier/_environment.text.erb
35
- - lib/exception_notifier/views/exception_notifier/exception_notification.text.erb
36
- - lib/exception_notifier/views/exception_notifier/_session.text.erb
37
36
  - lib/exception_notifier/views/exception_notifier/_request.text.erb
37
+ - lib/exception_notifier/views/exception_notifier/_session.text.erb
38
38
  - lib/exception_notifier/views/exception_notifier/_title.text.erb
39
- - lib/exception_notifier/notifier.rb
39
+ - lib/exception_notifier/views/exception_notifier/exception_notification.text.erb
40
40
  - lib/exception_notifier.rb
41
41
  has_rdoc: true
42
42
  homepage: http://github.com/railsware/exception_notification
@@ -71,6 +71,6 @@ rubyforge_project:
71
71
  rubygems_version: 1.3.7
72
72
  signing_key:
73
73
  specification_version: 3
74
- summary: Exception notification by email for Rails apps
74
+ summary: Exception notification by email for Rails 3 apps
75
75
  test_files: []
76
76