Hi, i would like to use resteasys client proxy framework as its nice to have an interface to communicate with.
My interface on the server side looks like:
The code on the client (interface definition) is:
The client code is:
When i try to use the client, i do not get an exception as expected. The server throws the exception and puts it into the responses entity. This is working as expected. But on the client side, it seems like the exception is simply ignored. I would at least expect a string representation inside the response's entity of the exception. But there is nothing, it is null.
So i tried to tell resteasy it should use my exceptionmapper (the lines above which are commented), but that does not work neither. I did not find any documentation how to create such a (valid) ClientConfiguration.
The exceptionmapper i created is:
Can someone tell me how i can register this mapper so i can use the client code like this:
Unfortunately, RESTeasy, Jersey and probably any JAX-RS implementation does not handle server side exceptions the way we would like to. Instead, the code throws an implementation specific exception. In RESTeasy that's (I think) a RedirectionException (3xx), a ClientErrorException (4xx) or a ServerErrorException (5xx). For all, you can get the response from the exception, which you may need to parse to convert into the original exception. Using an ExceptionMapper makes that step easier because you can turn exceptions into responses you can more easily convert back.
ExceptionMapper is a server-side mechanism - it turns an exception into a response. On the client side it no longer exists. You will need to catch the ClientErrorException separately, and manually convert it back to the proper exception (convert the response back into an exception). There is no mechanism for that in JAX-RS.