title: RESTEasy Client Exception Handling
body: <p>I have a simple client using RESTEasy as follows:</p>
  
  <pre><code>public class Test {
      public static void main(String[] args) {
          ResteasyClient client = new ResteasyClientBuilder().build();
          ResteasyWebTarget target = client.target("http://localhost");
          client.register(new MyMapper());
          MyProxy proxy = target.proxy(MyProxy.class);
          String r = proxy.getTest();
      }
  }
  
  public interface MyProxy {
     @GET
     @Path("test")
     String getTest();
  }
  
  @Provider
  public class MyMapper implements ClientExceptionMapper&lt;BadRequestException&gt;{
  
      @Override
      public RuntimeException toException(BadRequestException arg0) {
          // TODO Auto-generated method stub
          System.out.println("mapped a bad request exception");
          return null;
      }
  
  }
  </code></pre>
  
  <p>The server is configured to return a <code>400 - Bad Request</code> on <code>http://localhost/test</code> along with a helpful message. A <code>BadRequestException</code> is being thrown by <code>ClientProxy</code>. Other than wrapping in <code>try/catch</code>, how can I make <code>getTest()</code> catch the exception and return the Response's helpful message as a string. I tried various <code>ClientExceptionMapper</code> implementations, but just can seem to get it right. The above code doesn't ever call <code>toException</code>. What am I missing here?</p>
  
  <p>My current work-around is to use a <code>ClientResponseFilter</code> and then do a <code>setStatus(200)</code> and stuff the original status in the response entity. This way I avoid the exception throws. </p>