In a REST service, is returning a 504 status code appropriate when the application times out waiting for a database query and is unable to complete the client's request?
504 Gateway Timeout
The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
Currently we're just showing a generic 500 error, which gets displayed in a UI as a generic server error. There is some utility in showing to the user that it is a database timeout error (perhaps along with suggestions to reduce the scope of what they're asking for), because at the least they're armed with more useful information if they contact whoever is responsible for their server.
Any pointers to how other REST services handle a database timeout?