Skip to content

Commit

Permalink
Merge pull request #511 from SuperPat45/patch-1
Browse files Browse the repository at this point in the history
Show the return error message instead of undefined when OSRMv1 HTTP r…
  • Loading branch information
perliedman authored Feb 20, 2019
2 parents 3916d6a + d74ab69 commit 8b7a084
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/osrm-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,16 @@
error.message = 'Error parsing OSRM response: ' + ex.toString();
}
} else {
error.message = 'HTTP request failed: ' + err.type +
(err.target && err.target.status ? ' HTTP ' + err.target.status + ': ' + err.target.statusText : '');
var message = err.type + (err.target && err.target.status ? ' HTTP ' + err.target.status + ': ' + err.target.statusText : '');
if (err.responseText) {
try {
data = JSON.parse(err.responseText);
if (data.message)
message = data.message;
} catch (ex) {
}
}
error.message = 'HTTP request failed: ' + message;
error.url = url;
error.status = -1;
error.target = err;
Expand Down

0 comments on commit 8b7a084

Please sign in to comment.