Skip to content

Show error message if file upload fails #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
simontaurus opened this issue Mar 31, 2025 · 2 comments
Closed

Show error message if file upload fails #17

simontaurus opened this issue Mar 31, 2025 · 2 comments

Comments

@simontaurus
Copy link
Collaborator

e.g. because file type is not allowed

@ademolaomosanya
Copy link
Contributor

Hello @simontaurus i would love to fix this issue
i have fixed a similar issue in cat-a-lot gadget for mediawiki, where the page is stuck at a protected file and the error is not handled properly, i created an error dialg and fix the api to handle the error properly.
I want to complete this task by making changes to the error-handling scripts, MwJson_editor.js and MwJson_api.js.
By adding of pre-upload validations for file sizes and types, the display of error messages in MwJson_editor.js before the upload even begins, and the addition of detailed messages for failure cases such as duplicate files or name conflicts in MwJson_api.js will give users better feedback on why the file upload failed.
I would appreciate feedback on whether there are other validation to be handle for file uploads or any specific detail i need to know.

@simontaurus
Copy link
Collaborator Author

Sounds great!

Uploading a file triggers mwjson.api.updatePage() of the File Page

mwjson.api.updatePage(page).done((page) => {

whicht triggers the file uploaded if needed:

const hasChangedFile = ('file' in page && page.file.changed);

finally calling uploadFile()

}).fail(function (retStatus, data) {

Probably the error is not correctly detected there or the promise.reject() cascade is somewhere wrong.
Making a pre-upload validations to fail early sound like a good idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants