DEV Community

Nandini Tayal
Nandini Tayal

Posted on

How to send a custom response when destination is down?

I am using Spring Cloud Gateway(Netty)

If the destination service is down the gateway throws *java.net.ConnectException: finishConnect(..) failed: Connection refused * and return a default response

Response returned -
{
"timestamp": "2022-09-30T10:45:15.593+00:00",
"path": "/myDestinationPath",
"status": 500,
"error": "Internal Server Error",
"requestId": "12345-6"
}

Is there any way to send a custom/decorated response instead of this default response?

Top comments (0)