summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/graceful_timeout_handling.rb
blob: 490c0ec3b1d2a44e6f9a0067f4014c607283a6ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

module GracefulTimeoutHandling
  extend ActiveSupport::Concern

  included do
    rescue_from ActiveRecord::QueryCanceled do |exception|
      raise exception unless request.format.json?

      log_exception(exception)

      render json: { error: _('There is too much data to calculate. Please change your selection.') }
    end
  end
end