I am trying to find ways how to get an exception propagated from RESTEasy reference binding to the Bean component invoking that REST service.
So, I have a Bean. It invokes a remote REST service via RESTEasy composite reference. Java interface defines a method with an exception, say void foo() throws MyException. The idea is to transform HTTP status code (say 404) into MyException AND let it propagate to my Bean code. I am using MessageComposer and ExceptionMapper. Still cannot make it. I can easily translate HTTP status to the exception (in Composer) but MyException does not get propagated to the bean which invokes the remote service.
I can explain this problem by using rest-binding quickstart. OrderServiceImpl.addItems() method invokes _warehouse.getItem(), which may throw ItemNotFoundException in some cases. Imagine, you would put try/catch block into this code, so that you can catch this exception and do some other logic. I tried. I was not able to get ItemNotFoundException eventhough it was generated by CustomComposer. Instead, I am getting following error:
01:33:30,821 ERROR [org.switchyard.component.resteasy.OutboundHandler] (http-/127.0.0.1:8080-2) SWITCHYARD038019: Unexpected exception composing inbound REST response: org.switchyard.quickstarts.rest.binding.ItemNotFoundException: Item not found
at org.switchyard.quickstarts.rest.binding.CustomComposer.compose(CustomComposer.java:49) [switchyard-rest-binding.jar:]
at org.switchyard.quickstarts.rest.binding.CustomComposer.compose(CustomComposer.java:35) [switchyard-rest-binding.jar:]
at org.switchyard.component.resteasy.OutboundHandler.handleMessage(OutboundHandler.java:146) [switchyard-component-resteasy-2.0.0.Final.jar:2.0.0.Final]
at org.switchyard.handlers.ProviderHandler.handleMessage(ProviderHandler.java:77) [switchyard-runtime-2.0.0.Final.jar:2.0.0.Final]
Any idea how to get an exception propagated in this scenario? Is it possible at all? Which other SwitchYard concept should be used to make this flow working?