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

Handle error for error with GET request #1

Open
bruceceng opened this issue Feb 26, 2021 · 1 comment
Open

Handle error for error with GET request #1

bruceceng opened this issue Feb 26, 2021 · 1 comment

Comments

@bruceceng
Copy link

It looks like the intention was to call the callback function for error handling if a URL string was passed to unzip. However if there is an error like 404 (Not Found), there is still an error thrown on the xhr.send() line.

try { xhr.open('GET', source) xhr.responseType = 'blob' xhr.send() } catch (err) { callback(err) }

I think that to properly catch the error, you need to add a handler like this: xhr.addEventListener('error', handleEvent); since the error is asynchronous and the try block has already successfully executed the send() command before the error is generate.

@bruceceng
Copy link
Author

Actually, it looks like the problem has to do with logging in the browser, not with the error handling. See https://stackoverflow.com/questions/30426277/catch-a-404-error-for-xhr. I will investigate further.

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

1 participant