Sha256: 140056395ee7db48bf4999f1b1dbf6a14cc8e16ef32776c04d9caaad27012db6

Contents?: true

Size: 1.35 KB

Versions: 31

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true
module Blacklight::Base
  extend ActiveSupport::Concern

  include Blacklight::Configurable
  include Blacklight::SearchHelper

  include Blacklight::SearchContext

  included do
    # When Blacklight::Exceptions::InvalidRequest is raised, the rsolr_request_error method is executed.
    # The index action will more than likely throw this one.
    # Example, when the standard query parser is used, and a user submits a "bad" query.
    rescue_from Blacklight::Exceptions::InvalidRequest, with: :handle_request_error if respond_to? :rescue_from
  end

  protected

  # when The index throws an error (Blacklight::Exceptions::InvalidRequest), this method is executed.
  def handle_request_error(exception)
    if Rails.env.development? || Rails.env.test?
      raise exception # Rails own code will catch and give usual Rails error page with stack trace
    else

      flash_notice = I18n.t('blacklight.search.errors.request_error')

      # If there are errors coming from the index page, we want to trap those sensibly

      if flash[:notice] == flash_notice
        logger.error "Cowardly aborting rsolr_request_error exception handling, because we redirected to a page that raises another exception"
        raise exception
      end

      logger.error exception

      flash[:notice] = flash_notice 
      redirect_to root_path
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
blacklight-6.25.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.24.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.23.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.22.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.21.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.20.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.19.2 app/controllers/concerns/blacklight/base.rb
blacklight-6.19.1 app/controllers/concerns/blacklight/base.rb
blacklight-6.19.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.18.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.17.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.16.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.15.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.14.1 app/controllers/concerns/blacklight/base.rb
blacklight-6.14.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.13.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.12.0 app/controllers/concerns/blacklight/base.rb
blacklight-6.11.2 app/controllers/concerns/blacklight/base.rb
blacklight-6.11.1 app/controllers/concerns/blacklight/base.rb
blacklight-6.11.0 app/controllers/concerns/blacklight/base.rb