I have a scenario in Zuul where the service that the URL is routed too might be down . So the reponse body gets thrown with 500 HTTP Status and ZuulException in the JSON bod
I had the same problem and was able to solve it in simpler way
Just put this into you Filter run()
method
if (<your condition>) {
ZuulException zuulException = new ZuulException("User message", statusCode, "Error Details message");
throw new ZuulRuntimeException(zuulException);
}
and SendErrorFilter
will deliver to the user the message with the desired statusCode
.
This Exception in an Exception pattern does not look exactly nice, but it works here.