me_exceptional 0.1.0 → 0.1.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.
@@ -1,4 +1,6 @@
|
|
1
|
-
class MeExceptional::Mailer <
|
1
|
+
class MeExceptional::Mailer < ActionMailer::Base
|
2
|
+
|
3
|
+
default :from => MeExceptional.mailer_from
|
2
4
|
|
3
5
|
def exceptional(message, params)
|
4
6
|
@message, @params = message, params
|
@@ -9,7 +11,7 @@ class MeExceptional::Mailer < ::ActionMailer::Base
|
|
9
11
|
|
10
12
|
def error_mail(message, params)
|
11
13
|
@message, @params = message, params
|
12
|
-
subject = "
|
14
|
+
subject = "[EXCEPTION] #{message}"
|
13
15
|
mail(:from => MeExceptional.mailer_from, :to => MeExceptional.mailer_to, :subject => subject)
|
14
16
|
end
|
15
17
|
|
@@ -4,30 +4,30 @@ module MeExceptional
|
|
4
4
|
module BasicExtension
|
5
5
|
|
6
6
|
def exception_catcher(e)
|
7
|
-
if Rails.env == 'production'
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
:timestamp => Time.zone.now)
|
8
|
+
message = "#{e.class}: #{e.message}"
|
9
|
+
content = {:backtrace => e.backtrace.join("\n"), :timestamp => Time.zone.now}
|
12
10
|
|
13
|
-
|
14
|
-
|
11
|
+
m = MeExceptional::Mailer.error_mail(message, content)
|
12
|
+
m.deliver
|
15
13
|
|
16
|
-
|
17
|
-
raise e
|
14
|
+
Rails.logger.error "[EXCEPTION] #{e.class}: #{e.message}"
|
18
15
|
end
|
19
16
|
|
20
17
|
module ClassMethods
|
18
|
+
|
21
19
|
def rescue_mail_from_methods(*methods)
|
22
20
|
|
23
21
|
methods.each do |method|
|
24
22
|
class_eval <<-EOF
|
25
|
-
|
26
|
-
|
23
|
+
alias_method :#{method}_non_rescuable, :#{method}
|
24
|
+
|
25
|
+
def #{method}(*args)
|
26
|
+
#{method}_non_rescuable(*args)
|
27
27
|
rescue Exception => e
|
28
|
-
|
28
|
+
exception_catcher(e)
|
29
|
+
#rescue_with_handler(e)
|
29
30
|
end
|
30
|
-
alias_method :#{method}, :#{method}_rescuable
|
31
31
|
EOF
|
32
32
|
end
|
33
33
|
|
@@ -36,12 +36,6 @@ module MeExceptional
|
|
36
36
|
|
37
37
|
def self.included(base)
|
38
38
|
base.extend(ClassMethods)
|
39
|
-
|
40
|
-
base.instance_eval <<-EOF
|
41
|
-
include ActiveSupport::Rescuable
|
42
|
-
rescue_from Exception, :with => :exception_catcher
|
43
|
-
EOF
|
44
|
-
|
45
39
|
end
|
46
40
|
|
47
41
|
end
|
@@ -49,3 +43,4 @@ module MeExceptional
|
|
49
43
|
end
|
50
44
|
|
51
45
|
|
46
|
+
|
data/lib/me_exceptional.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: me_exceptional
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kai Rubarth
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activesupport
|