refactoring: use Util.getError
This commit is contained in:
parent
c3b07eb576
commit
5a10a3a8f7
1 changed files with 2 additions and 12 deletions
|
|
@ -69,16 +69,6 @@ L.BRouter = L.Class.extend({
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
|
|
||||||
_getError: function(xhr) {
|
|
||||||
var msg = 'no response from server';
|
|
||||||
if (xhr.responseText) {
|
|
||||||
msg = xhr.responseText;
|
|
||||||
} else if (this.status || this.statusText) {
|
|
||||||
msg = this.status + ': ' + this.statusText;
|
|
||||||
}
|
|
||||||
return new Error(msg);
|
|
||||||
},
|
|
||||||
|
|
||||||
getRoute: function(latLngs, cb) {
|
getRoute: function(latLngs, cb) {
|
||||||
var url = this.getUrl(latLngs),
|
var url = this.getUrl(latLngs),
|
||||||
xhr = new XMLHttpRequest();
|
xhr = new XMLHttpRequest();
|
||||||
|
|
@ -90,7 +80,7 @@ L.BRouter = L.Class.extend({
|
||||||
xhr.open('GET', url, true);
|
xhr.open('GET', url, true);
|
||||||
xhr.onload = L.bind(this._handleRouteResponse, this, xhr, cb);
|
xhr.onload = L.bind(this._handleRouteResponse, this, xhr, cb);
|
||||||
xhr.onerror = L.bind(function(xhr, cb) {
|
xhr.onerror = L.bind(function(xhr, cb) {
|
||||||
cb(this._getError(xhr));
|
cb(BR.Util.getError(xhr));
|
||||||
}, this, xhr, cb);
|
}, this, xhr, cb);
|
||||||
xhr.send();
|
xhr.send();
|
||||||
},
|
},
|
||||||
|
|
@ -112,7 +102,7 @@ L.BRouter = L.Class.extend({
|
||||||
|
|
||||||
return cb(null, layer);
|
return cb(null, layer);
|
||||||
} else {
|
} else {
|
||||||
cb(this._getError(xhr));
|
cb(BR.Util.getError(xhr));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue