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

Error handling for 404 (e.g.) #131

Open
tudacs opened this issue Jan 15, 2022 · 1 comment
Open

Error handling for 404 (e.g.) #131

tudacs opened this issue Jan 15, 2022 · 1 comment

Comments

@tudacs
Copy link

tudacs commented Jan 15, 2022

Recently I tried handling '404 Not found'-errors while loading GPX-data by the 'error'-event, as the README reads like this should be the way to handle it.

This failed, as the corresponding parts of the code (_load_xml) only call the event-firing callback (in _parse) if the return code equals 200.

As a rather quick'n'dirty workaround, I added 'error'-event-firing in _load_xml for req.status == 404 for my use-case and would like to request comments or ideas how to handle this (more) properly.

Ideas so far:

  • discard req.status == 200-condition. Should/Would keep a single point of firing 'error', but fails currently, as _parse_xml_data expects a proper (gpx-)xml-document. Maybe add a try-catch block around calling _parse_xml_data?
  • add a else-branch and fire 'error' in _load_xml. From my point of view this might be a problem for 206 Partial, e.g., given I'm not that familiar with how XMLHttpRequest is designed regarding this.
@tudacs
Copy link
Author

tudacs commented Jan 15, 2022

Implementation for the both mentioned ideas can be found here:

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