Netflix Feign - Propagate Status and Exception through Microservices

后端 未结 6 786
予麋鹿
予麋鹿 2021-02-05 05:04

I\'m using Netflix Feign to call to one operation of a Microservice A to other other operation of a Microservice B which validates a code using Spring Boot.

The operation

6条回答
  •  北海茫月
    2021-02-05 05:11

    Write your custom exception mapper and register it. You can customize responses.

    Complete example is here

    public class GenericExceptionMapper implements ExceptionMapper {
    
        @Override
        public Response toResponse(Throwable ex) {
            return Response.status(500).entity(YOUR_RETURN_OBJ_HERE).build();
        }
    
    }
    

提交回复
热议问题