DEV: Do not re-throw in popupAjaxError (#13462)

Effectively reverts 3ddc33b07c

Makes the failure states testable; see the uncommented test.

I don't think we're re-catching these errors anyway?

_update:_
We did in a single instance in discourse-code-review but it wasn't really intentional and I fixed it in https://github.com/discourse/discourse-code-review/pull/73
This commit is contained in:
Jarek Radosz 2021-06-22 19:29:20 +02:00 committed by GitHub
parent ee87d8c93b
commit fe5923da06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 39 deletions

View File

@ -64,13 +64,5 @@ export function throwAjaxError(undoCallback) {
} }
export function popupAjaxError(error) { export function popupAjaxError(error) {
if (error && error._discourse_displayed) {
return;
}
bootbox.alert(extractError(error)); bootbox.alert(extractError(error));
error._discourse_displayed = true;
// We re-throw in a catch to not swallow the exception
throw error;
} }

View File

@ -333,38 +333,38 @@ acceptance(
} }
); );
// acceptance( acceptance(
// "Managing Group Email Settings - SMTP and IMAP Enabled - Email Test Invalid", "Managing Group Email Settings - SMTP and IMAP Enabled - Email Test Invalid",
// function (needs) { function (needs) {
// needs.user(); needs.user();
// needs.settings({ enable_smtp: true, enable_imap: true }); needs.settings({ enable_smtp: true, enable_imap: true });
// needs.pretender((server, helper) => { needs.pretender((server, helper) => {
// server.post("/groups/47/test_email_settings", () => { server.post("/groups/47/test_email_settings", () => {
// return helper.response(400, { return helper.response(422, {
// success: false, success: false,
// errors: [ errors: [
// "There was an issue with the SMTP credentials provided, check the username and password and try again.", "There was an issue with the SMTP credentials provided, check the username and password and try again.",
// ], ],
// }); });
// }); });
// }); });
// test("enabling IMAP, testing, and saving", async function (assert) { test("enabling IMAP, testing, and saving", async function (assert) {
// await visit("/g/discourse/manage/email"); await visit("/g/discourse/manage/email");
// await click("#enable_smtp"); await click("#enable_smtp");
// await click("#prefill_smtp_gmail"); await click("#prefill_smtp_gmail");
// await fillIn('input[name="username"]', "myusername@gmail.com"); await fillIn('input[name="username"]', "myusername@gmail.com");
// await fillIn('input[name="password"]', "password@gmail.com"); await fillIn('input[name="password"]', "password@gmail.com");
// await click(".test-smtp-settings"); await click(".test-smtp-settings");
// assert.equal( assert.equal(
// query(".modal-body").innerText, query(".modal-body").innerText,
// "There was an issue with the SMTP credentials provided, check the username and password and try again.", "There was an issue with the SMTP credentials provided, check the username and password and try again.",
// "shows a dialogue with the error message from the server" "shows a dialogue with the error message from the server"
// ); );
// await click(".modal-footer .btn.btn-primary"); await click(".modal-footer .btn.btn-primary");
// }); });
// } }
// ); );