mpetazzoni / leaflet-gpx

A GPX track plugin for Leaflet.js
http://mpetazzoni.github.io/leaflet-gpx
BSD 2-Clause "Simplified" License
529 stars 114 forks source link

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

Open tudacs opened 2 years ago

tudacs commented 2 years ago

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:

tudacs commented 2 years ago

Implementation for the both mentioned ideas can be found here: