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

File API NotFoundError not handled by config.error callback #81

Closed
jelazos7 opened this issue Aug 26, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@jelazos7
Copy link

commented Aug 26, 2014

I am testing how PapaParse handles local files that are not found. I expected PapaParse's error callback to be invoked with FileReader's NotFoundError as a parameter, but neither the error callback nor complete callback seem to be called.

To reproduce in Chrome:

  • Use any PapaParse example that operates on local files
  • Run the example in debug mode and set a break point after the input[type=file] change event occurs but before Papa.parse is called.
  • When the break point is hit, delete the selected file (to cause the NotFoundError to occur)
  • resume execution

I am new to PapaParse, so if there is an alternate way i should be detecting FileReader errors, please advise. Below is my somewhat-redacted development code:

function handleFileAPIError(err) {
        switch (err.name) {
                case 'NotFoundError':
                        // handle NotFoundError
                        break;
                case: ...// handle other errors
        }
};

function parseCsv(csvFile) {        
        debugger;
        Papa.parse(csvFile, {
                error : handleFileAPIError,
                complete: function(results) {
                        // handle results
                }
        });
}

@mholt

This comment has been minimized.

Copy link
Owner

commented Aug 26, 2014

I think this is a bug, but the funny thing is I can't find any evidence in the documentation that I ever intended for this to work... it might have been an oversight.

However, selecting files using the jQuery plugin does support an error handler. If you have jQuery on your page, you can use jQuery which will use the error handler.

But I suppose having an error handler is necessary even when not using jQuery. I'm glad you pointed this out. I will look into adding this for 3.1.

@mholt

This comment has been minimized.

Copy link
Owner

commented Aug 26, 2014

@jelazos7 The latest commit, 091ccff, should now invoke the error callback. Let me know if it still gives you trouble, but as far as I can tell, your code looks right. Thanks again!

@mholt mholt closed this Aug 26, 2014

@mholt mholt added confirmed bug and removed under review labels Aug 26, 2014

@jelazos7

This comment has been minimized.

Copy link
Author

commented Aug 28, 2014

Awesome! Thanks, i'll give it a shot

@mholt mholt modified the milestone: 3.1 Sep 1, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.