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
|
||||
//gpxLayer.fire('data:loaded');
|
||||
|
||||
try {
|
||||
geojson = JSON.parse(xhr.responseText);
|
||||
layer = L.geoJson(geojson).getLayers()[0];
|
||||
|
||||
return cb(null, layer);
|
||||
} catch(e) {
|
||||
console.error(e, xhr.responseText);
|
||||
return cb(e);
|
||||
}
|
||||
} else {
|
||||
cb(BR.Util.getError(xhr));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue