openrouteservice-r icon indicating copy to clipboard operation
openrouteservice-r copied to clipboard

Account for different error response formats

Open aoles opened this issue 7 years ago • 1 comments

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!

aoles avatar Jun 12 '18 13:06 aoles

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": []
}

aoles avatar Jun 12 '18 14:06 aoles