Hi See this FAQ http://camel.apache.org/why-is-the-exception-null-when-i-use-onexception.html
You can also some how to do this on this page http://camel.apache.org/exception-clause.html If you have a copy of Camel in Action book, then section 5.5 covers such a use case to only handle certain conditions from a http response code. On Thu, Mar 28, 2013 at 10:02 AM, vss123 <vss...@gmail.com> wrote: > Oh sorry.. I did not explain clearly.We wanted to throw different exceptions > for 4xx and 5xx errors and handle them differently. The problem is that we > do not know how to get the exception object. We tried this > handle[HttpOperationFailedException]{ process(new Processor { > def process(exchange: Exchange) { val httpStatusCode = > exchange.getIn.getHeader(Exchange.HTTP_RESPONSE_CODE) > if(httpStatusCode.toString.startsWith("5")) throw new > ServerHttpErrorException > if(httpStatusCode.toString.startsWith("4")) throw new > ClientHttpErrorException throw new Exception } }) > }.handled(true) > The httpStatusCode was /null/. We guess probably because it was thrown and > not set on the exchange. We tried /getException/.But that, too is /null/ > Then we tried this, > class ReThrower { def doIt(httpException: HttpOperationFailedException){ > if(httpException.getStatusCode.toString.startsWith("5")) throw new > ServerHttpErrorException > if(httpException.getStatusCode.toString.startsWith("4")) throw new > ClientHttpErrorException throw httpException > }}handle[HttpOperationFailedException]().handled(true).onWhen(bean(classOf[ReThrower], > "doIt")) > We got /java.util.NoSuchElementException: head of empty list/ when running. > Could you give us ideas on how to go about this? > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Retry-based-on-HTTP-response-codes-tp5729939p5730016.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen