stanford-oval / thingpedia-common-devices

Thingpedia interface code for commonly used devices
Other
38 stars 28 forks source link

Handle 504 error in Yelp #405

Open gcampax opened 3 years ago

gcampax commented 3 years ago

On occasion, Yelp requests time out with error 504:

Failed to invoke query HTTPError: Unexpected HTTP error 504 in request to https://api.yelp.com/v3/businesses/search?limit=50&sort_by=best_match&locale=en_US&latitude=37.442156&longitude=-122.1634471&categories=restaurants
    at IncomingMessage.<anonymous> (/home/travis/build/stanford-oval/thingpedia-common-devices/node_modules/thingpedia/dist/helpers/http.js:139:35)
    at IncomingMessage.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 504,
  url: 'https://api.yelp.com/v3/businesses/search?limit=50&sort_by=best_match&locale=en_US&latitude=37.442156&longitude=-122.1634471&categories=restaurants',
  detail: `{"error": {"code": "REQUEST_TIMED_OUT", "description": "The request timed out, please try again later. If this continues, please create an issue on GitHub with the request you're making: https://github.com/Yelp/yelp-fusion/issues"}}`
}

We should catch the error, convert it to a well-defined error code, and then show a meaningful message to the user.