FIX: Confusing vague upload error (#23347)

When an upload fails and we don't have a specific error, we
show a generic one. But it's a little too generic -- it doesn't
even include the file name.

This commit shows the file name so you at least know which of your
uploads failed.
This commit is contained in:
Martin Brennan 2023-08-31 18:02:00 +10:00 committed by GitHub
parent 5a810fd6cc
commit 253d4a154c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -329,14 +329,14 @@ export function displayErrorForUpload(data, siteSettings, fileName) {
}
// otherwise, display a generic error message
dialog.alert(I18n.t("post.errors.upload"));
dialog.alert(I18n.t("post.errors.upload", { file_name: fileName }));
}
function displayErrorByResponseStatus(status, body, fileName, siteSettings) {
switch (status) {
// didn't get headers from server, or browser refuses to tell us
case 0:
dialog.alert(I18n.t("post.errors.upload"));
dialog.alert(I18n.t("post.errors.upload", { file_name: fileName }));
return true;
// entity too large, usually returned from the web server

View File

@ -390,7 +390,9 @@ module("Unit | Utility | uploads", function (hooks) {
"test.png"
);
assert.ok(
dialog.alert.calledWith(I18n.t("post.errors.upload")),
dialog.alert.calledWith(
I18n.t("post.errors.upload", { file_name: "test.png" })
),
"the alert is called"
);
});

View File

@ -3465,7 +3465,7 @@ en:
errors:
create: "Sorry, there was an error creating your post. Please try again."
edit: "Sorry, there was an error editing your post. Please try again."
upload: "Sorry, there was an error uploading that file. Please try again."
upload: "Sorry, there was an error uploading %{file_name}. Please try again."
file_too_large: "Sorry, that file is too big (maximum size is %{max_size_kb}kb). Why not upload your large file to a cloud sharing service, then paste the link?"
file_size_zero: "Sorry, it looks like something has gone wrong, the file you are trying to upload is 0 bytes. Please try again."
file_too_large_humanized: "Sorry, that file is too big (maximum size is %{max_size}). Why not upload your large file to a cloud sharing service, then paste the link?"