Skip to content

Commit

Permalink
Fix error object when an HTTP error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
Per Liedman committed Oct 14, 2016
1 parent 9529c7d commit fbe6c26
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/L.Routing.OSRMv1.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,18 @@
return this._routeDone(data, wps, options, callback, context);
} catch (ex) {
error.status = -3;
error.error = ex.toString();
error.message = ex.toString();
}
} catch (ex) {
error.status = -2;
error.error = 'Error parsing OSRM response: ' + ex.toString();
error.message = 'Error parsing OSRM response: ' + ex.toString();
}
} else {
error = L.extend({}, err, {
error: 'HTTP request failed: ' + err.type,
status: -1
})
error.message = 'HTTP request failed: ' + err.type +
(err.target.status ? ' HTTP ' + err.target.status + ': ' + err.target.statusText : '');
error.url = url;
error.status = -1;
error.target = err;
}

callback.call(context || callback, error);
Expand Down

0 comments on commit fbe6c26

Please sign in to comment.