Skip to content

Commit

Permalink
make sure we don't set env["airbrake.error_id"] for async notices
Browse files Browse the repository at this point in the history
Setting this makes no sense, since this value is only used for informing
the end user about the ID of the exception that she experienced. If
Airbrake is used asynchronously, notice will probably be sent in the
background, after the response.

Closing airbrake#154
  • Loading branch information
shime committed Jan 5, 2013
1 parent 81b350c commit a62d321
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/airbrake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def send_notice(notice)
if configuration.public?
if configuration.async?
configuration.async.call(notice)
nil # make sure we never set env["airbrake.error_id"] for async notices
else
sender.send_to_airbrake(notice)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/airbrake/user_informer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def replacement(with)

def call(env)
status, headers, body = @app.call(env)

if env['airbrake.error_id'] && Airbrake.configuration.user_information
new_body = []
replace = replacement(env['airbrake.error_id'])
Expand All @@ -20,6 +21,7 @@ def call(env)
headers['Content-Length'] = new_body.sum(&:bytesize).to_s
body = new_body
end

[status, headers, body]
end
end
Expand Down

0 comments on commit a62d321

Please sign in to comment.