notify-on-error 1.0.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.
@@ -0,0 +1,7 @@
1
+ class ErrorMailer < ActionMailer::Base
2
+
3
+ def exception_email ex
4
+ @ex = ex
5
+ mail( :to => NotifyOnError.email_to, :from => NotifyOnError.email_from, :subject => 'An Exception Occurred' )
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ <h1> An exception has occurred: </h1>
2
+ <h3><%= @ex.exception %></h3>
3
+ <p><%= @ex.backtrace %></p>
@@ -0,0 +1,34 @@
1
+ module NotifyOnError
2
+ ## Define ControllerMethods
3
+ module Controller
4
+ ## this one manages the usual self.included, klass_eval stuff
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ rescue_from 'Exception' do |ex|
9
+ Rails.logger.error( "Exception found #{ex.exception}")
10
+ Rails.logger.error( "Parameters #{params.inspect}")
11
+ Rails.logger.error( ex.backtrace.join("\n") )
12
+ unless NotifyOnError.notification_environments.map(&:to_s).include?( Rails.env )
13
+ Rails.logger.error( "Supressing notification because of environment(#{Rails.env})" )
14
+ return
15
+ end
16
+
17
+ case NotifyOnError.notification_method
18
+ when :action_mailer
19
+ Rails.logger.error( "Notify via ActionMailer" )
20
+ ErrorMailer.exception_email(ex).deliver
21
+ else
22
+ Rails.logger.error( "Unrecognized notification method(#{NotifyOnError.notification_method})" )
23
+ end
24
+ end
25
+ end
26
+
27
+ module InstanceMethods
28
+ end
29
+
30
+ end
31
+ end
32
+
33
+ ::ActionController::Base.send :include, NotifyOnError::Controller
34
+
@@ -0,0 +1,12 @@
1
+ require 'rails'
2
+ require 'notify_on_error'
3
+
4
+ module NotifyOnError
5
+ class Engine < Rails::Engine
6
+
7
+ #get @ app
8
+ #initializer "my_railtie.configure_rails_initialization" do |app|
9
+ #end
10
+
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ require 'noe/engine' if defined?(Rails)
2
+ require 'application_controller'
3
+
4
+ module NotifyOnError
5
+ mattr_accessor :notification_method
6
+ @@notification_method = nil
7
+
8
+ mattr_accessor :notification_environments
9
+ @@notification_environments = nil
10
+
11
+ mattr_accessor :email_from
12
+ @@email_from = nil
13
+
14
+ mattr_accessor :email_to
15
+ @@email_to = nil
16
+
17
+ def self.setup
18
+ yield self
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: notify-on-error
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Paul Santa Clara
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-08-12 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description:
22
+ email: psantaclara@relaynetwork.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - app/mailers/error_mailer.rb
31
+ - app/views/error_mailer/exception_email.html.erb
32
+ - lib/application_controller.rb
33
+ - lib/noe/engine.rb
34
+ - lib/notify_on_error.rb
35
+ has_rdoc: true
36
+ homepage:
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ segments:
49
+ - 0
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.3.6
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Let the developer know when a controller expception is allowed to bubble up.
65
+ test_files: []
66
+