wellcomecollection / catalogue-api

:crystal_ball: The API for searching the Wellcome Collection catalogue.
https://developers.wellcomecollection.org
MIT License
4 stars 0 forks source link

Customise the akka-http timeout response to be JSON #631

Closed alexwlchan closed 1 year ago

alexwlchan commented 1 year ago

The front-end expects that the catalogue API will always return errors in JSON, but if we get a timeout we're returning the default akka-http response:

The server was not able to produce a timely response to your request.
Please try again in a short while!⏎

This wraps that error in our JSON error type, which should make it easier for the front-end to handle.

I considered adding a test for this, but this particular query doesn't timeout with an empty index (unsurprisingly) and I don't think it's worth the time to get a full repro.

For https://github.com/wellcomecollection/platform/issues/5665