Search code examples
springexceptionnetflix-zuulspring-cloud-netflix

Is it possible to route exception in Spring Cloud?


I'm trying to figure out if it is possible to handle all exceptions that had been thrown by the bunch of microservices in certain one.

For example, i have microservice called ui. It handles all ui related stuff and serves as a Zuul gateway. It contains custom error page. Also i have microservice called foo. When foo throws exception i want ui to handle it i.e show ui's custom error page. I dont want foo or any other service to contain any error pages.

Is there a way to achieve such behavior?


Solution

  • I would suggest using an error controller and then having all your micro services redirect to that uri when experiencing an error.

    Check out this tutorial he explains setting up a custom error page pretty well.

    http://www.baeldung.com/custom-error-page-spring-mvc