Skip to content
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

Show error message, when files are not accessible #322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oschwede
Copy link

@oschwede oschwede commented Sep 10, 2021

Description

The dropzone component reads from the selected file to gather and display additional information about the selected file(s). Errors thrown while reading lead to react crashing. Those kind of errors are neither catched, nor catchable by the parent component.

This PR:

  • adds the necessary catch and displays the affected files as an error notification
  • adds a new prop that allows customizing the error messages (similar to the success message when files have been added)

Related:

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested

On Linux:

  • Create a file
  • Change permissions to 400 (only file owner can read)
  • Change the fileowner to someone else, e.g. root
  • Try to select that file with the dropzone
  • Without this PR, react will crash because the error thrown by FileReader API is not catched
  • With this PR, the error will be handled gracefully

Alternatively you can try uploading a very large file, e.g. a few GB. This also results in a FileReader error
Test Configuration:

  • Browser:
  • Firefox 92

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

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

Successfully merging this pull request may close these issues.

1 participant