Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
explicitly set format for api requests in application controller if r…
Browse files Browse the repository at this point in the history
…outing error
  • Loading branch information
kelly-croswell committed Sep 19, 2019
1 parent 016d68a commit 76643cc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ class ApplicationController < ActionController::Base
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized

rescue_from ActionController::RoutingError do |exception|
request.format = 'json' if api_request?
logger.error 'Routing error occurred'
respond_to do |format|
format.html { render 'shared/404', status: 404 }
format.json { render :json => { status: 'error', message: 'The page you were looking for could not be found! If you were searching for a specific object or file, check to make sure you have the correct identifier and try again. If you believe you have reached this message in error, please contact your administrator or an APTrust administrator.' }, status: 404 }
format.json { render :json => { status: 'error', message: 'The page you were looking for could not be found! If you were searching for a specific object or file, check to make sure you have the correct identifier and try again. If you believe you have reached this message in error, please contact your administrator or an APTrust administrator.', url: request.original_url }, status: 404 }
end
end

Expand Down

0 comments on commit 76643cc

Please sign in to comment.