Class: DatashiftJourney::ErrorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/datashift_journey/errors_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/datashift_journey/errors_controller.rb', line 3

def show
  @exception = env['action_dispatch.exception']
  action = request.path[1..-1].gsub(/[^0-9]/, '')
  action = 500 if action.blank?

  status_code =
    if @exception
      trace = Rails.backtrace_cleaner.clean(@exception.backtrace)
      Rails.logger.fatal trace.join("#\n")

      ActionDispatch::ExceptionWrapper.new(env, @exception).status_code
    else
      action.to_i
    end

  respond_to do |format|
    format.html { render action: action, status: status_code }
    format.json { render json: { status: status_code, error: @exception.message } }
  end
end