You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Minh Tran <mi...@winning.com.au> on 2014/04/24 15:58:38 UTC

throwing custom exceptions in spring DSL

Hi 

It appears the only way to throw exceptions in the spring DSL is to declare the exception as a bean and use the <throwException> tag with the reference to the bean. However doing so means you're limited to whatever message you declared your bean with. e.g.

<bean id="myException" class="java.lang.RuntimeException">
	<constructor-arg>something bad happened</constructor-arg>
</bean>

So is it possible to throw an exception with a customised message? Or is this just a limitation of spring DSL? Would be awesome if I could do something like this 

<throwException>
	<bean class="java.lang.RuntimeException">
		<constructor-arg>my message</constructor-arg>
	</bean>
</throwException>

Re: throwing custom exceptions in spring DSL

Posted by Claus Ibsen <cl...@gmail.com>.
No you can only refer to the exception and define it as a <bean>

On Thu, Apr 24, 2014 at 3:58 PM, Minh Tran <mi...@winning.com.au> wrote:
> Hi
>
> It appears the only way to throw exceptions in the spring DSL is to declare the exception as a bean and use the <throwException> tag with the reference to the bean. However doing so means you're limited to whatever message you declared your bean with. e.g.
>
> <bean id="myException" class="java.lang.RuntimeException">
>         <constructor-arg>something bad happened</constructor-arg>
> </bean>
>
> So is it possible to throw an exception with a customised message? Or is this just a limitation of spring DSL? Would be awesome if I could do something like this
>
> <throwException>
>         <bean class="java.lang.RuntimeException">
>                 <constructor-arg>my message</constructor-arg>
>         </bean>
> </throwException>



-- 
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/