UX: show a generic error on upload for XHR status 0 (#10521)

This indication covers all cases of network errors, not just "cancelled by user".
The post upload component already has its own handling for user-cancelled uploads, but the generic upload component does not.

Tested by stopping my localhost server right before attempting to upload a file.
This commit is contained in:
Kane York 2020-08-25 12:08:03 -07:00 committed by GitHub
parent 7277ca6cb6
commit 93e136ae0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -269,8 +269,9 @@ export function getUploadMarkdown(upload) {
export function displayErrorForUpload(data, siteSettings) {
if (data.jqXHR) {
switch (data.jqXHR.status) {
// cancelled by the user
// didn't get headers from server, or browser refuses to tell us
case 0:
bootbox.alert(I18n.t("post.errors.upload"));
return;
// entity too large, usually returned from the web server

View File

@ -106,7 +106,7 @@ export default Mixin.create({
});
$upload.on("fileuploadfail", (e, data) => {
if (!data || data.errorThrown !== "abort") {
if (!data) {
displayErrorForUpload(data, this.siteSettings);
}
reset();