Skip to content

Commit a8b0bb3

Browse files
authored
Fix uncaught 422 and 500 errors (#11590)
1 parent 1bc077d commit a8b0bb3

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

app/controllers/application_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class ApplicationController < ActionController::Base
2525
rescue_from ActionController::InvalidAuthenticityToken, with: :unprocessable_entity
2626
rescue_from ActionController::UnknownFormat, with: :not_acceptable
2727
rescue_from Mastodon::NotPermittedError, with: :forbidden
28+
rescue_from HTTP::Error, OpenSSL::SSL::SSLError, with: :internal_server_error
2829

2930
before_action :store_current_location, except: :raise_not_found, unless: :devise_controller?
3031
before_action :require_functional!, if: :user_signed_in?
@@ -95,6 +96,10 @@ def not_acceptable
9596
respond_with_error(406)
9697
end
9798

99+
def internal_server_error
100+
respond_with_error(500)
101+
end
102+
98103
def single_user_mode?
99104
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.where('id > 0').exists?
100105
end

app/controllers/media_proxy_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class MediaProxyController < ApplicationController
77

88
before_action :authenticate_user!, if: :whitelist_mode?
99

10+
rescue_from ActiveRecord::RecordInvalid, with: :not_found
11+
1012
def show
1113
RedisLock.acquire(lock_options) do |lock|
1214
if lock.acquired?

0 commit comments

Comments
 (0)