title: JAX RS Client: Catch exception message while making a REST call
body: <p>I'm using ResteasyClient to make a REST client to my another service A. Say, service A throws an exception <strong>CustomException</strong> with a message : <strong>Got Invalid request.</strong>
  Here is how I am using the Client:</p>
  
  <pre><code>public Response callServiceA(final String query) {
      ResteasyClient client = new ResteasyClientBuilder().build();
      String link = "abc.com/serviceA";
      ResteasyWebTarget target = client.target(link).path("call");
      Form form = new Form();
      form.param("query", query);
      Response response;
      try {
          String data =
                  target.request(MediaType.APPLICATION_JSON_TYPE)
                          .post(Entity.entity(form,
                                  MediaType.APPLICATION_FORM_URLENCODED_TYPE),
                                  String.class);
          response = Response.ok().entity(data).build();
      } catch (Exception e) {
          String message = e.getMessage();
          e.printStackTrace();
          response = Response.serverError().entity(e.getMessage()).build();
      } finally{
          client.close();
      }
      return response;
  }
  </code></pre>
  
  <p>However, when I print the stacktrace, I'm unable to find my custom error message. I can just see the message as <strong>HTTP 400 Bad Request</strong>.
  Could you please suggest me how to access the error message?</p>
  
  <p><strong>NOTE:</strong> I am able to get the error message when I call the serviceA using the restClient. Hence, I dont think there is an issue with the service.</p>