Fix handling of non-409 errors in ExtensionsPage

If the error isn't a 409, we'll want to re-throw the error so it'll be handled by the default system (showing an alert).

For simplicity, we can also move 409-handling logic out of setTimeout.

Finally, we adjust the timeout to 300 milliseconds to match the modal transition animation length.
This commit is contained in:
Alexander Skvortsov 2020-10-09 19:27:07 -04:00
parent 95682d1e92
commit c7d496446b

View File

@ -139,16 +139,20 @@ export default class ExtensionsPage extends Page {
// TODO: This workaround should be removed when we move away from bootstrap JS for modals. // TODO: This workaround should be removed when we move away from bootstrap JS for modals.
setTimeout(() => { setTimeout(() => {
app.modal.close(); app.modal.close();
}, 300); // Bootstrap's Modal.TRANSITION_DURATION is 300 ms.
const error = JSON.parse(e.responseText).errors[0]; if (e.status !== 409) {
throw e;
}
app.alerts.show( const error = e.response.errors[0];
{ type: 'error' },
app.translator.trans(`core.lib.error.${error.code}_message`, { app.alerts.show(
extension: error.extension, { type: 'error' },
extensions: error.extensions.join(', '), app.translator.trans(`core.lib.error.${error.code}_message`, {
}) extension: error.extension,
); extensions: error.extensions.join(', '),
}, 250); })
);
} }
} }