aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/notifications
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-05-02 22:40:20 +0200
committerJosé Valim <jose.valim@gmail.com>2010-05-02 22:45:54 +0200
commita76c7e68d5e39f5962d9cb85c98e6a8e96f8b3af (patch)
tree3d08dcfb6f2f00b8bfb3e8cbce00504f6e6f26b0 /activesupport/lib/active_support/notifications
parent731d4392e478ff5526b595074d9caa999da8bd0c (diff)
downloadrails-a76c7e68d5e39f5962d9cb85c98e6a8e96f8b3af.tar.gz
rails-a76c7e68d5e39f5962d9cb85c98e6a8e96f8b3af.tar.bz2
rails-a76c7e68d5e39f5962d9cb85c98e6a8e96f8b3af.zip
Event should be aware if yielded block failed or not.
Diffstat (limited to 'activesupport/lib/active_support/notifications')
-rw-r--r--activesupport/lib/active_support/notifications/instrumenter.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb
index ef3fdd1843..7e89402822 100644
--- a/activesupport/lib/active_support/notifications/instrumenter.rb
+++ b/activesupport/lib/active_support/notifications/instrumenter.rb
@@ -12,14 +12,16 @@ module ActiveSupport
end
# Instrument the given block by measuring the time taken to execute it
- # and publish it.
+ # and publish it. Notice that events get sent even if an error occurs
+ # in the passed-in block
def instrument(name, payload={})
time = Time.now
begin
yield(payload) if block_given?
+ rescue Exception => e
+ payload[:exception] = [e.class.name, e.message]
+ raise e
ensure
- # Notify in an ensure block so that we can be certain end
- # events get sent even if an error occurs in the passed-in block
@notifier.publish(name, time, Time.now, @id, payload)
end
end