UX: Improve error message when a topic cannot be moved due to category restrictions (#20900)

This commit is contained in:
Natalie Tay
2023-03-31 02:18:57 +08:00
committed by GitHub
parent 58270954b6
commit 068a36d354
3 changed files with 12 additions and 1 deletions

View File

@ -361,7 +361,14 @@ class TopicsController < ApplicationController
category = Category.find_by(id: params[:category_id])
if category || (params[:category_id].to_i == 0)
guardian.ensure_can_move_topic_to_category!(category)
begin
guardian.ensure_can_move_topic_to_category!(category)
rescue Discourse::InvalidAccess
return(
render_json_error I18n.t("category.errors.move_topic_to_category_disallowed"),
status: :forbidden
)
end
else
return render_json_error(I18n.t("category.errors.not_found"))
end