failtale-reporter 0.2.0 → 0.2.1
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/lib/failtale_reporter/adapters/rails.rb +45 -43
- data/lib/failtale_reporter/version.rb +1 -1
- data/rails/init.rb +1 -2
- metadata +2 -2
@@ -1,51 +1,53 @@
|
|
1
1
|
|
2
2
|
module FailtaleReporter
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
rescue_action_in_public_without_failtale(exception)
|
36
|
-
end
|
37
|
-
|
38
|
-
protected
|
39
|
-
|
40
|
-
def is_private? #nodoc:
|
41
|
-
if defined?(RAILS_ENV)
|
42
|
-
['development', 'test'].include?(RAILS_ENV)
|
43
|
-
end
|
3
|
+
|
4
|
+
def self.force_public(flag=nil)
|
5
|
+
@force_public = flag unless flag.nil?
|
6
|
+
@force_public
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
module FailtaleReporter::Adapters::Rails
|
12
|
+
|
13
|
+
IGNORED_EXCEPTIONS = ['ActiveRecord::RecordNotFound',
|
14
|
+
'ActionController::RoutingError',
|
15
|
+
'ActionController::InvalidAuthenticityToken',
|
16
|
+
'CGI::Session::CookieStore::TamperedWithCookie']
|
17
|
+
|
18
|
+
IGNORED_EXCEPTIONS.map!{|e| eval(e) rescue nil }.compact!
|
19
|
+
IGNORED_EXCEPTIONS.freeze
|
20
|
+
|
21
|
+
def self.included(target)
|
22
|
+
target.send :alias_method_chain, :rescue_action_in_public, :failtale
|
23
|
+
|
24
|
+
FailtaleReporter.configure do |config|
|
25
|
+
config.ignored_exceptions IGNORED_EXCEPTIONS
|
26
|
+
config.default_reporter "rails"
|
27
|
+
config.application_root RAILS_ROOT
|
28
|
+
config.information_collector do |error, controller|
|
29
|
+
env = error.environment
|
30
|
+
env = env.merge(controller.request.env)
|
31
|
+
|
32
|
+
env.delete('action_controller.rescue.response')
|
33
|
+
env.delete('action_controller.rescue.request')
|
34
|
+
error.environment = env
|
44
35
|
end
|
45
|
-
|
46
36
|
end
|
47
|
-
|
48
37
|
end
|
38
|
+
|
39
|
+
def rescue_action_in_public_with_failtale(exception)
|
40
|
+
FailtaleReporter.report(exception, self) unless is_private?
|
41
|
+
rescue_action_in_public_without_failtale(exception)
|
42
|
+
end
|
43
|
+
|
44
|
+
protected
|
45
|
+
|
46
|
+
def is_private?
|
47
|
+
FailtaleReporter.force_public or (
|
48
|
+
defined?(Rails) and ['development', 'test'].include?(Rails.env))
|
49
|
+
end
|
50
|
+
|
49
51
|
end
|
50
52
|
|
51
53
|
::ActionController::Base.send :include, FailtaleReporter::Adapters::Rails
|
data/rails/init.rb
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
::FailtaleReporter.load_adapter('rails')
|
1
|
+
::FailtaleReporter.load_adapter('rails')
|