From 5a10a3a8f71eb993afec9c0c2439300700689310 Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Wed, 25 Mar 2015 11:30:38 +0100 Subject: [PATCH] refactoring: use Util.getError --- js/router/BRouter.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/js/router/BRouter.js b/js/router/BRouter.js index 1b49234..a615e03 100644 --- a/js/router/BRouter.js +++ b/js/router/BRouter.js @@ -69,16 +69,6 @@ L.BRouter = L.Class.extend({ 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) { var url = this.getUrl(latLngs), xhr = new XMLHttpRequest(); @@ -90,7 +80,7 @@ L.BRouter = L.Class.extend({ xhr.open('GET', url, true); xhr.onload = L.bind(this._handleRouteResponse, this, xhr, cb); xhr.onerror = L.bind(function(xhr, cb) { - cb(this._getError(xhr)); + cb(BR.Util.getError(xhr)); }, this, xhr, cb); xhr.send(); }, @@ -112,7 +102,7 @@ L.BRouter = L.Class.extend({ return cb(null, layer); } else { - cb(this._getError(xhr)); + cb(BR.Util.getError(xhr)); } },