diff options
author | Starfall <root@starfall.blue> | 2020-02-04 17:44:29 -0600 |
---|---|---|
committer | Starfall <root@starfall.blue> | 2020-02-04 17:44:29 -0600 |
commit | 6d24d3bcb84abd04f31da95f97f6d60ef0afdc00 (patch) | |
tree | e7c38251a9e92bdf3a464b4aa7f1880aa5139bf0 /app/controllers/application_controller.rb | |
parent | c0c9529df269816f52915a9802e5e30fbce9576b (diff) | |
parent | 885e9227c6e8e1ce5e4a5625d5126ba76dce2c00 (diff) |
Merge branch 'glitch'
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f1a4f0d02..c882d40ab 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -25,6 +25,7 @@ class ApplicationController < ActionController::Base rescue_from ActionController::InvalidAuthenticityToken, with: :unprocessable_entity rescue_from ActionController::UnknownFormat, with: :not_acceptable rescue_from ActionController::ParameterMissing, with: :bad_request + rescue_from Paperclip::AdapterRegistry::NoHandlerError, with: :bad_request rescue_from ActiveRecord::RecordNotFound, with: :not_found rescue_from Mastodon::NotPermittedError, with: :forbidden rescue_from HTTP::Error, OpenSSL::SSL::SSLError, with: :internal_server_error @@ -211,7 +212,12 @@ class ApplicationController < ActionController::Base end def respond_with_error(code) - use_pack 'error' - render "errors/#{code}", layout: 'error', status: code, formats: [:html] + respond_to do |format| + format.any do + use_pack 'error' + render "errors/#{code}", layout: 'error', status: code, formats: [:html] + end + format.json { render json: { error: Rack::Utils::HTTP_STATUS_CODES[code] }, status: code } + end end end |