def call(env)
      # Set the request data for bugsnag middleware to use
      Bugsnag.configuration.set_request_data(:rack_env, env)
      if Bugsnag.configuration.auto_capture_sessions
        Bugsnag.start_session
      end

      begin
        response = @app.call(env)
      rescue Exception => raised
        # Notify bugsnag of rack exceptions
        Bugsnag.notify(raised, true) do |report|
          report.severity = "error"
          report.severity_reason = {
            :type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
            :attributes => Bugsnag::Rack::FRAMEWORK_ATTRIBUTES
          }
        end

        # Re-raise the exception
        raise
      end

      # Notify bugsnag of rack exceptions
      if env["rack.exception"]
        Bugsnag.notify(env["rack.exception"], true) do |report|
          report.severity = "error"
          report.severity_reason = {
            :type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
            :attributes => FRAMEWORK_ATTRIBUTES
          }
        end
      end

      response
    ensure
      # Clear per-request data after processing the each request
      Bugsnag.configuration.clear_request_data
    end
def call(env)
      # Set the request data for bugsnag middleware to use
      Bugsnag.configuration.set_request_data(:rack_env, env)
      if Bugsnag.configuration.auto_capture_sessions
        Bugsnag.start_session
      end

      begin
        response = @app.call(env)
      rescue Exception => raised
        # Notify bugsnag of rack exceptions
        Bugsnag.notify(raised, true) do |report|
          report.severity = "error"
          report.severity_reason = {
            :type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
            :attributes => Bugsnag::Rack::FRAMEWORK_ATTRIBUTES
          }
        end

        # Re-raise the exception
        raise
      end

      # Notify bugsnag of rack exceptions
      if env["rack.exception"]
        Bugsnag.notify(env["rack.exception"], true) do |report|
          report.severity = "error"
          report.severity_reason = {
            :type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
            :attributes => FRAMEWORK_ATTRIBUTES
          }
        end
      end

      response
    ensure
      # Clear per-request data after processing the each request
      Bugsnag.configuration.clear_request_data
    end
Wraps a call to the application with error capturing