Skip to content
  • Janko Marohnić's avatar
    53adf53b
    Handle throwing in controller action in log subscriber · 53adf53b
    Janko Marohnić authored
    When throw was used in a controller action, and there is matching catch
    around the request in a Rack middleware, then :exception won't be
    present in the event payload.
    
    This is because ActiveSupport::Notifications::Instrumenter.instrument
    sets :exception in a rescue handler, but rescue is never called in a
    throw/catch scenario:
    
      catch(:halt) do
        begin
          throw :halt
        rescue Exception => e
          puts "rescue" # never reached
        ensure
          puts "ensure"
        end
      end
    
    Missing :exception was actually handled prior to Rails 6.1.0, but an
    optimization updated the code to assume this was present. So this can be
    considered a regression fix.
    53adf53b
    Handle throwing in controller action in log subscriber
    Janko Marohnić authored
    When throw was used in a controller action, and there is matching catch
    around the request in a Rack middleware, then :exception won't be
    present in the event payload.
    
    This is because ActiveSupport::Notifications::Instrumenter.instrument
    sets :exception in a rescue handler, but rescue is never called in a
    throw/catch scenario:
    
      catch(:halt) do
        begin
          throw :halt
        rescue Exception => e
          puts "rescue" # never reached
        ensure
          puts "ensure"
        end
      end
    
    Missing :exception was actually handled prior to Rails 6.1.0, but an
    optimization updated the code to assume this was present. So this can be
    considered a regression fix.
Loading