camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vss123 <>
Subject Re: Retry based on HTTP response codes
Date Thu, 28 Mar 2013 09:02:31 GMT
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 =
if(httpStatusCode.toString.startsWith("5")) throw new
if(httpStatusCode.toString.startsWith("4")) throw new
ClientHttpErrorException            throw new Exception        }      })   
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
if(httpException.getStatusCode.toString.startsWith("4")) throw new
ClientHttpErrorException    throw httpException 
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:
Sent from the Camel - Users mailing list archive at
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message