Instructions on the offical blog for Exceptional.context are wrong

mislav's Avatar


21 Oct, 2010 01:05 PM

At first we used the instructions outlined in the blog post Send extra data with your exceptions

But eventually we discovered a problem: any exceptions happening in non-authenticated requests had :user_id and :email in them, too. These values were seemingly random, but after a short while we concluded they are from the first previous authenticated request that was performed without raising an exception. In short, Exceptional.context doesn't get cleared on the end of the normal request, and the values stay in the current thread until the first exception is raised.

So instead of the before_filter, my recommendation is to hook into rescue_action itself to provide context:

include {
  def rescue_action(exception)
    if logged_in? and not exception_handled_by_rescue_from?(exception)
      Exceptional.context(:user_id =>, :email =>

This is not tested, just an example of a more optimal solution. The same context will get cleared after the exception has been reported (normal Exceptional behavior).

  1. 1 Posted by Wal McConnell on 21 Oct, 2010 01:18 PM

    Wal McConnell's Avatar

    Hey Mislav,

    Yep, good spot, the docs for this need some work, I'll steal your suggestion as one of the mechanisms for using it .

    appreciate you letting us know,


  2. Wal McConnell closed this discussion on 21 Oct, 2010 01:18 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac