RomKal wrote:
> You can always use try/catch construct to catch the exception and
> create appropriate response before it goes back to mina.
>
> An example can be found here:
Thank you Romek, that looks good.
But I think I found an even better way, idiomatic and extremely succinct.
What I need to do is:
(a) prevent redelivery attempts;
(b) short-circuit the pipeline;
(c) access the exception and use it to build the new exchange.out.body;
(d) prevent exchange.exception from being set (because MinaConsumer
would want to send exchange.exception instead of exchange.out.body).
It seems that I can achieve all these goals, globally for all routes,
with just these few lines of code:
onException(Exception.class)
.handled(true)
.process(new Processor() {
public void process(Exchange exchange) {
Throwable exception = (Throwable)
exchange.getProperty(DeadLetterChannel.EXCEPTION_CAUSE_PROPERTY);
exchange.getOut().setBody(myExceptionFormatter(exception));
}
});
--
View this message in context:
http://www.nabble.com/HttpProducer%3A-how-to-access-the-body-of-an-error-page--tp20475651s22882p20676917.html
Sent from the Camel - Users mailing list archive at Nabble.com.