Sha256: c5bf4b290fc54ed1331992439bc2d85af1ff7f9dfaae8cfd949602c608f02be0

Contents?: true

Size: 1.35 KB

Versions: 13

Compression:

Stored size: 1.35 KB

Contents

# -*- encoding : utf-8 -*-
module Blacklight::Base   
  extend ActiveSupport::Concern

  include Blacklight::Configurable
  include Blacklight::SolrHelper

  require 'blacklight/catalog/search_context'
  include Blacklight::Catalog::SearchContext

  included do  
    # When RSolr::RequestError 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 RSolr::Error::Http, :with => :rsolr_request_error if respond_to? :rescue_from
  end

  protected

  # when solr (RSolr) throws an error (RSolr::RequestError), this method is executed.
  def rsolr_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

13 entries across 13 versions & 1 rubygems

Version Path
blacklight-5.7.2 lib/blacklight/base.rb
blacklight-5.5.4 lib/blacklight/base.rb
blacklight-5.7.1 lib/blacklight/base.rb
blacklight-5.7.0 lib/blacklight/base.rb
blacklight-5.6.0 lib/blacklight/base.rb
blacklight-5.5.3 lib/blacklight/base.rb
blacklight-5.5.2 lib/blacklight/base.rb
blacklight-5.5.1 lib/blacklight/base.rb
blacklight-5.5.0 lib/blacklight/base.rb
blacklight-5.4.0 lib/blacklight/base.rb
blacklight-5.4.0.rc1 lib/blacklight/base.rb
blacklight-5.3.0 lib/blacklight/base.rb
blacklight-5.2.0 lib/blacklight/base.rb