You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by restful camel <bi...@gmail.com> on 2014/12/11 22:19:31 UTC

REST DSL Exception Handling

Hi,

Newbie to Camel. I want to handle a specific exception (JsonParseException)
which is thrown when the Rest webservice configured in the camelContext
(Spring DSL) is invoked. Right now, the JsonParseException is being caught
by the Camel Context Error handler - however, I want to be able to write a
specific onException block that will handle this exception and send back
appropriate response to the user. How can I achieve this? I tried writing an
onException block in the camelContext to handle this, but apparently the
thrown exception is not being handled within that block.

Thanks!
Restful Camel :)



--
View this message in context: http://camel.465427.n5.nabble.com/REST-DSL-Exception-Handling-tp5760600.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: REST DSL Exception Handling

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Thanks for trying. I logged a ticket to support this in next release
https://issues.apache.org/jira/browse/CAMEL-8155

On Mon, Dec 15, 2014 at 8:01 PM, restful camel <bi...@gmail.com> wrote:
> This is when the Json request comes in to the webservice. I am deliberately
> sending in a malformed Json object, just so that I can handle it - our
> service will be called by various applications, and I want to be able to
> send a response back to the caller with the message that the Json is
> malformed.
>
> I tried setting the bridgeErrorHandler property, but it does not help. See
> below for the configuration in Spring:
>
>                 <restConfiguration bindingMode="auto" component="restlet" port="8085">
>                         <consumerProperty key="bridgeErrorHandler" value="true"/>
>                 </restConfiguration>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/REST-DSL-Exception-Handling-tp5760600p5760714.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: REST DSL Exception Handling

Posted by restful camel <bi...@gmail.com>.
This is when the Json request comes in to the webservice. I am deliberately
sending in a malformed Json object, just so that I can handle it - our
service will be called by various applications, and I want to be able to
send a response back to the caller with the message that the Json is
malformed.

I tried setting the bridgeErrorHandler property, but it does not help. See
below for the configuration in Spring:

		<restConfiguration bindingMode="auto" component="restlet" port="8085">
			<consumerProperty key="bridgeErrorHandler" value="true"/>
		</restConfiguration>




--
View this message in context: http://camel.465427.n5.nabble.com/REST-DSL-Exception-Handling-tp5760600p5760714.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: REST DSL Exception Handling

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Where does this exception happen?

You can try setting consumer.bridgeErrorHandler=true
http://camel.apache.org/why-does-my-file-consumer-not-pick-up-the-file-and-how-do-i-let-the-file-consumer-use-the-camel-error-handler.html

You would need to set this with rest-dsl as a consumer property
http://camel.apache.org/rest-dsl

restConfiguration().component("jetty").port(9091).consumerProperty("bridgeErrorHandler",
"true");

On Thu, Dec 11, 2014 at 10:19 PM, restful camel <bi...@gmail.com> wrote:
> Hi,
>
> Newbie to Camel. I want to handle a specific exception (JsonParseException)
> which is thrown when the Rest webservice configured in the camelContext
> (Spring DSL) is invoked. Right now, the JsonParseException is being caught
> by the Camel Context Error handler - however, I want to be able to write a
> specific onException block that will handle this exception and send back
> appropriate response to the user. How can I achieve this? I tried writing an
> onException block in the camelContext to handle this, but apparently the
> thrown exception is not being handled within that block.
>
> Thanks!
> Restful Camel :)
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/REST-DSL-Exception-Handling-tp5760600.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/