camel-users mailing list archives

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.