Skip to content

A platform for community discussion. Free, open, simple.

FIX: Show specific server error when moving posts fails (#37634)

Régis Hanol4aca86b6960d
diff --git a/frontend/discourse/app/components/modal/move-to-topic.gjs b/frontend/discourse/app/components/modal/move-to-topic.gjs
index d7cf3e6b46b..d0009762ede 100644
--- a/frontend/discourse/app/components/modal/move-to-topic.gjs
+++ b/frontend/discourse/app/components/modal/move-to-topic.gjs
@@ -14,6 +14,7 @@ import PluginOutlet from "discourse/components/plugin-outlet";
import RadioButton from "discourse/components/radio-button";
import TextField from "discourse/components/text-field";
import lazyHash from "discourse/helpers/lazy-hash";
+import { extractError } from "discourse/lib/ajax-error";
import { applyValueTransformer } from "discourse/lib/transformer";
import DiscourseURL from "discourse/lib/url";
import { mergeTopic, movePosts } from "discourse/models/topic";
@@ -180,8 +181,8 @@ export default class MoveToTopic extends Component {
this.args.closeModal();
this.args.model.toggleMultiSelect();
DiscourseURL.routeTo(result.url);
- } catch {
- this.flash = i18n("topic.move_to.error");
+ } catch (e) {
+ this.flash = extractError(e, i18n("topic.move_to.error"));
} finally {
this.saving = false;
}
diff --git a/frontend/discourse/tests/acceptance/topic-move-posts-test.js b/frontend/discourse/tests/acceptance/topic-move-posts-test.js
index 17ee98add36..72141788326 100644
--- a/frontend/discourse/tests/acceptance/topic-move-posts-test.js
+++ b/frontend/discourse/tests/acceptance/topic-move-posts-test.js
@@ -62,7 +62,9 @@ acceptance("Topic move posts", function (needs) {
await click(".selected-posts .move-to-topic");
await fillIn(".choose-topic-modal #split-topic-name", "Existing topic");
await click(".choose-topic-modal .d-modal__footer .btn-primary");
- assert.dom("#modal-alert").hasText(i18n("topic.move_to.error"));
+ assert
+ .dom("#modal-alert")
+ .hasText(i18n("generic_error_with_reason", { error: "Invalid title" }));
});
test("moving all posts", async function (assert) {