rack_bugzscout 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack_bugzscout.rb +10 -9
- metadata +1 -1
data/lib/rack_bugzscout.rb
CHANGED
@@ -2,9 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'bugzscout'
|
3
3
|
|
4
4
|
module Rack
|
5
|
-
# Catches all exceptions raised
|
6
|
-
# sends a useful email with the exception, stacktrace, and
|
7
|
-
# contents of the environment.
|
5
|
+
# Catches all exceptions raised, and submits them to FogBugz via BugzScout.
|
8
6
|
|
9
7
|
class BugzScout
|
10
8
|
attr_reader :fogbugz_url, :fogbugz_user, :fogbugz_project, :fogbugz_area
|
@@ -22,8 +20,6 @@ module Rack
|
|
22
20
|
begin
|
23
21
|
@app.call(env)
|
24
22
|
rescue => boom
|
25
|
-
# TODO don't allow exceptions from send_notification to
|
26
|
-
# propogate
|
27
23
|
send_notification boom, env
|
28
24
|
raise
|
29
25
|
end
|
@@ -33,16 +29,21 @@ module Rack
|
|
33
29
|
|
34
30
|
private
|
35
31
|
def send_notification(exception, env)
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
# wrapping this so we can avoid sending these up the chain
|
33
|
+
# not entirely sure that this is the right thing to do...
|
34
|
+
begin
|
35
|
+
if %w(staging production).include?(ENV['RACK_ENV'])
|
36
|
+
FogBugz::BugzScout.submit(@fogbugz_url) do |scout|
|
39
37
|
scout.user = @fogbugz_user
|
40
38
|
scout.project = @fogbugz_project
|
41
39
|
scout.area = @fogbugz_area
|
42
40
|
scout.title = exception.class.name
|
43
41
|
scout.body = exception.message
|
44
42
|
end
|
45
|
-
|
43
|
+
env['bugzscout.submitted'] = true
|
44
|
+
end
|
45
|
+
rescue => error
|
46
|
+
# maybe we ought to log something here?
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|