title: How to catch FeignClient exception
body: <p>I try to catch exception wich I received from another microservice connected by FeignClient. I've made custom ErrorDecoder, and </p>
  
  <pre><code>public class CustomErrorDecoder implements ErrorDecoder {
  
      private final Logger log = LoggerFactory.getLogger(getClass());
  
      private final ErrorDecoder defaultErrorDecoder = new Default();
  
      @Override
      public Exception decode(String methodKey, Response response) {
  
          if (response.status() &gt;= 400 &amp;&amp; response.status() &lt;= 499) {
              log.info("----------------- "+methodKey+" , "+response.status()+" , "+ response.reason());
              return new RestApiException(99,99,"");
          }
          return defaultErrorDecoder.decode(methodKey, response);
      }
  } 
  </code></pre>
  
  <p>Where RestApiException extends Exception.</p>
  
  <pre><code>@ControllerAdvice
  public class GlobalControllerAdvice {
  
      private final Logger log = LoggerFactory.getLogger(getClass());
  
      @ExceptionHandler(RestApiException.class)
      public ResponseEntity&lt;RestApiException&gt; handleException(RestApiException exception, HttpServletRequest req) {
          log.error("Sending error to client ( "+req.getUserPrincipal().getName()+" ) \"{}\"", exception.getErrMsg());
          return new ResponseEntity&lt;RestApiException&gt;(exception, exception.getStatus());
      }
  
      @ExceptionHandler(Throwable.class)
      public ResponseEntity&lt;RestApiException&gt; handleException(Throwable throwable, HttpServletRequest req) {
          RestApiException exception=new RestApiException(HttpStatus.INTERNAL_SERVER_ERROR, 100, 100,
                  throwable.getMessage());
          return handleException(exception, req);
      }
  </code></pre>
  
  <p>As a result, when I get &lt;--- HTTP/1.1 400 Bad Request (5380ms)
  I've got default error messages</p>
  
  <p>HttpStatus.INTERNAL_SERVER_ERROR, 100, 100,
                      throwable.getMessage());</p>
  
  <p>but not expexted custom exception, which I try to set in CustomErrorDecoder.  </p>
  
  <p>What I'm doing wrong, why I can't  call RetAppiException and return error answer to rest client.</p>
  
  <p>Thanks.</p>