Skip to content

Commit fbe6c26

Browse files
author
Per Liedman
committed
Fix error object when an HTTP error occurs
1 parent 9529c7d commit fbe6c26

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/L.Routing.OSRMv1.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,18 @@
8080
return this._routeDone(data, wps, options, callback, context);
8181
} catch (ex) {
8282
error.status = -3;
83-
error.error = ex.toString();
83+
error.message = ex.toString();
8484
}
8585
} catch (ex) {
8686
error.status = -2;
87-
error.error = 'Error parsing OSRM response: ' + ex.toString();
87+
error.message = 'Error parsing OSRM response: ' + ex.toString();
8888
}
8989
} else {
90-
error = L.extend({}, err, {
91-
error: 'HTTP request failed: ' + err.type,
92-
status: -1
93-
})
90+
error.message = 'HTTP request failed: ' + err.type +
91+
(err.target.status ? ' HTTP ' + err.target.status + ': ' + err.target.statusText : '');
92+
error.url = url;
93+
error.status = -1;
94+
error.target = err;
9495
}
9596

9697
callback.call(context || callback, error);

0 commit comments

Comments
 (0)