camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Getting a Header property on a exception in the DSL
Date Tue, 20 Aug 2013 14:58:26 GMT
This is not possible as you use the new constructor in Java that will
instantiate the exception once.

What you want is to create a new exception when it happens with data
from the message. For that you can call a method and let it throw the

For throwException to work with your use case, it would require to not
use the new constructor, and let Camel instantiate the exception and
evaluate eg any simple expresisons prior etc.

eg we could do something alike,

throwException(ConfigurationNotFoundException.class, simple("Something
got wrong due ${}"))

which then would create the exception using a 1 arg constructor,
assuming that would be a String type etc.

Though when you need 2+ args then it gets more complicated.

Also we should also try to avoid keep expanding the DSL to avoid it
growing to large. Though I can see your use-case is probably more
common to create an exception with a cause String message that has
details from the Camel message.

If other feel we need something a like this, then we could raise a JIRA

On Tue, Aug 20, 2013 at 2:25 PM, abdiels <> wrote:
> barthorre,
>     First, thanks for replying and second, I do that all the time too!!!
> However, in this particular it does not work.  Look at the code, I am
> passing it when throwing the exception, it is not in the regular DSL where
> simple will just work.  You can try it and you will see.  What comes in the
> Exception string is:  Client Configuration not found for clientid:
> ${header.ClientID}.  If you try to add simple around it, it does not work
> since simple returns a SimpleBuilder so I tried the other code that I showed
> on my post, but I am not sure how to get the exchange so I have not been
> able to get the value here.
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Red Hat, Inc.
Twitter: davsclaus
Author of Camel in Action:

View raw message