Implement specific errors with ClientErrorInterceptor
In cases where Client Proxy methods do not return Response or ClientResponse, it may be not be desireable for the Client Proxy Framework to throw generic ClientResponseFailure exceptions. In these scenarios, where more fine-grained control of thrown Exceptions is required, the ClientErrorInterceptor API may be used. public static T getClientService(final Class clazz, final String serverUri) { ResteasyProviderFactory pf = ResteasyProviderFactory.getInstance(); pf.addClientErrorInterceptor(new DataExceptionInterceptor()); System.out.println("Generating REST service for: " + clazz.getName()); return ProxyFactory.create(clazz, serverUri); } ClientErrorInterceptor provides a hook into the proxy ClientResponse request lifecycle. If a Client Proxy method is called, resulting in a client exception, and the proxy return type is not Response or ClientResponse, registered interceptors will be given a chance to process the response manually, or throw a new exception. If all interceptors successfully return, RestEasy will re-throw the original encountered exception. Note, however, that the response input stream may need to be reset before additional reads will succeed.