Catch JSON.parse SyntaxError to show error message (#53)
This commit is contained in:
parent
514cc705ef
commit
d9862d6cd2
1 changed files with 8 additions and 3 deletions
|
|
@ -98,10 +98,15 @@ L.BRouter = L.Class.extend({
|
||||||
// leaflet.spin
|
// leaflet.spin
|
||||||
//gpxLayer.fire('data:loaded');
|
//gpxLayer.fire('data:loaded');
|
||||||
|
|
||||||
geojson = JSON.parse(xhr.responseText);
|
try {
|
||||||
layer = L.geoJson(geojson).getLayers()[0];
|
geojson = JSON.parse(xhr.responseText);
|
||||||
|
layer = L.geoJson(geojson).getLayers()[0];
|
||||||
|
|
||||||
return cb(null, layer);
|
return cb(null, layer);
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e, xhr.responseText);
|
||||||
|
return cb(e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cb(BR.Util.getError(xhr));
|
cb(BR.Util.getError(xhr));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue