openrouteservice-r
openrouteservice-r copied to clipboard
Account for different error response formats
API error responses might have different formats, such as:
{
"error": "Key not authorised"
}
{
"error": {
"code": 2001,
"message": "Parameter 'profile' is missing."
},
"info": {
"engine": {
"version": "4.5.0",
"build_date": "2018-03-26T13:41:46Z"
},
"timestamp": 1528811534758
}
}
{
"code": 4000,
"message": "Invalid JSON object in request"
}
Add test for this!
Geocoding API uses yet another error response format.
{
"geocoding": {
"version": "0.2",
"attribution": "/v1/attribution",
"query": {
"size": 10,
"private": false,
"lang": {
"name": "English",
"iso6391": "en",
"iso6393": "eng",
"defaulted": false
},
"querySize": 20
},
"errors": [
"invalid param 'text': text length, must be >0"
],
"engine": {
"name": "Pelias",
"author": "Mapzen",
"version": "1.0"
},
"timestamp": 1528812928983
},
"type": "FeatureCollection",
"features": []
}