Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 84107 invoked from network); 30 Sep 2010 20:52:56 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Sep 2010 20:52:56 -0000 Received: (qmail 92383 invoked by uid 500); 30 Sep 2010 20:52:56 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 92332 invoked by uid 500); 30 Sep 2010 20:52:56 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 92324 invoked by uid 99); 30 Sep 2010 20:52:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Sep 2010 20:52:55 +0000 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=FREEMAIL_FROM,SPF_HELO_PASS,SPF_NEUTRAL,T_TO_NO_BRKTS_FREEMAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: 216.139.236.158 is neither permitted nor denied by domain of p3tr.matousek@gmail.com) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Sep 2010 20:52:51 +0000 Received: from sam.nabble.com ([192.168.236.26]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1P1Q7C-0004xq-D8 for users@camel.apache.org; Thu, 30 Sep 2010 13:52:30 -0700 Date: Thu, 30 Sep 2010 13:52:30 -0700 (PDT) From: mat127 To: users@camel.apache.org Message-ID: <1285879950400-3047644.post@n5.nabble.com> In-Reply-To: <1285856141148-3047083.post@n5.nabble.com> References: <1285854260534-3047023.post@n5.nabble.com> <1285856141148-3047083.post@n5.nabble.com> Subject: Re: Restlet HTTP status and message MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi Ashwin, thank you for your answer. You are right there is no exception handling in the code I posted. That is because the exception that is raised during the route execution is related to the parsing of the http response: SEVERE: Failed delivery for exchangeId: 26a0911d-9ffc-4366-9c46-cef2084e6a24. Exhausted after delivery attempt: 1 caught: org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: java.io.ByteArrayInputStream@1f0d7f5; line: 1, column: 2] org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: java.io.ByteArrayInputStream@1f0d7f5; line: 1, column: 2] at org.codehaus.jackson.impl.JsonParserBase._constructError(JsonParserBase.java:651) at org.codehaus.jackson.impl.JsonParserBase._reportError(JsonParserBase.java:635) at org.codehaus.jackson.impl.JsonParserBase._reportUnexpectedChar(JsonParserBase.java:576) at org.codehaus.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:194) at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:1039) at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:995) at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:818) at org.apache.camel.component.jackson.JacksonDataFormat.unmarshal(JacksonDataFormat.java:70) ... But this parsing is useless in case that HTTP status is not 200 as the body of the message does not contain expected JSON data but html error message instead. Handling this kind of exception would mean that the data is corrupted but received fine which is not true. That is why I want to find some access to http status that restlet component has received from the server and avoid any parsing (by filtering e.g.) in case it is not 200 OK. Imagine the route without the unmarshalling: In this case there will be no exception even the REST API would respond with some HTTP status != 200. Anyway the exchange.getOut.isFailed() is false too as you can see from the log: [DEBUG] [2010-09-30 14:57:47,018] [main] c.b.i.c.a.l.ExchangeHeadersInspector: exchange.failed: false Petr -- View this message in context: http://camel.465427.n5.nabble.com/Restlet-HTTP-status-and-message-tp3047023p3047644.html Sent from the Camel - Users mailing list archive at Nabble.com.