From 81bf581aa95307dae83a8d08f174e25a44370aa5 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Tue, 11 May 2021 10:36:57 +0200 Subject: [PATCH] DEV: rescues site setting missing exception (#13022) This will allow to correctly catch it client side and display a correct error. --- app/controllers/application_controller.rb | 4 ++++ config/locales/server.en.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 000cd89701e..cf444e8709e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -152,6 +152,10 @@ class ApplicationController < ActionController::Base render_json_error e.message, status: 400 end + rescue_from Discourse::SiteSettingMissing do |e| + render_json_error I18n.t('site_setting_missing', name: e.message), status: 500 + end + rescue_from ActionController::RoutingError, PluginDisabled do rescue_discourse_actions(:not_found, 404) end diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 23b159e73ad..1ae0740aa4a 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -3940,6 +3940,8 @@ en: page_forbidden: title: "Oops! That page is private." + site_setting_missing: "`%{name}` site setting has to be set." + page_not_found: title: "Oops! That page doesn’t exist or is private." popular_topics: "Popular"