You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Trevv <45...@safe-mail.net> on 2009/02/06 03:05:10 UTC

throwFault DSL doesn't actually throw?

I added a .throwFault at the end of a .choice, as suggested near the end of
the  http://camel.apache.org/message-router.html Message Router  wiki page. 
But I found that .throwFault doesn't actually throw anything.  Is there a
different DSL command, for throwing an exception?  Is .throwFault documented
somewhere, aside from the brief mention at the end of the Message Router
page?
-- 
View this message in context: http://www.nabble.com/throwFault-DSL-doesn%27t-actually-throw--tp21865262s22882p21865262.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: throwFault DSL doesn't actually throw?

Posted by Hadrian Zbarcea <hz...@gmail.com>.
Trevv,

Although throwing an exception from a processor would work, this would  
be just a workaround.  We have a throwFault() and it should work.   
Keep in mind though that faults and exceptions are different.  If you  
want faults to be treated like exceptions there's also a handleFault()  
api.  Now that you pointed this out we absolutely must document this  
better.  Please see an example in action at:
http://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FaultRouteTest.java


Have fun riding the camel.
Hadrian

On Feb 6, 2009, at 12:15 AM, Claus Ibsen wrote:

> You can use a processor and throw an exception from it
>
> process(new Processor()...
> // and throw exception here
>
> On Fri, Feb 6, 2009 at 3:16 AM, Willem Jiang  
> <wi...@gmail.com> wrote:
>> Hi,
>>
>> Can you give me the whole picture of your DSL?
>> maybe you should use end() to close the block.
>>
>> Willem
>>
>> Trevv wrote:
>>> I added a .throwFault at the end of a .choice, as suggested near  
>>> the end of
>>> the  http://camel.apache.org/message-router.html Message Router   
>>> wiki page.
>>> But I found that .throwFault doesn't actually throw anything.  Is  
>>> there a
>>> different DSL command, for throwing an exception?  Is .throwFault  
>>> documented
>>> somewhere, aside from the brief mention at the end of the Message  
>>> Router
>>> page?
>>
>>
>
>
>
> -- 
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/


Re: throwFault DSL doesn't actually throw?

Posted by Claus Ibsen <cl...@gmail.com>.
You can use a processor and throw an exception from it

process(new Processor()...
// and throw exception here

On Fri, Feb 6, 2009 at 3:16 AM, Willem Jiang <wi...@gmail.com> wrote:
> Hi,
>
> Can you give me the whole picture of your DSL?
> maybe you should use end() to close the block.
>
> Willem
>
> Trevv wrote:
>> I added a .throwFault at the end of a .choice, as suggested near the end of
>> the  http://camel.apache.org/message-router.html Message Router  wiki page.
>> But I found that .throwFault doesn't actually throw anything.  Is there a
>> different DSL command, for throwing an exception?  Is .throwFault documented
>> somewhere, aside from the brief mention at the end of the Message Router
>> page?
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: throwFault DSL doesn't actually throw?

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

Can you give me the whole picture of your DSL?
maybe you should use end() to close the block.

Willem

Trevv wrote:
> I added a .throwFault at the end of a .choice, as suggested near the end of
> the  http://camel.apache.org/message-router.html Message Router  wiki page. 
> But I found that .throwFault doesn't actually throw anything.  Is there a
> different DSL command, for throwing an exception?  Is .throwFault documented
> somewhere, aside from the brief mention at the end of the Message Router
> page?


Re: throwFault DSL doesn't actually throw?

Posted by Trevv <45...@safe-mail.net>.
Gee, I was wondering why no one answered my question.  Now I see that several
people answered, almost a week ago.  I never saw the answers, because all of
your messages are missing from the Nabble forum.

I think that .throwFault was actually working correctly (i.e. working as
designed) but I was surprised at first that it didn't actually "throw"
something, in the JLS sense of the word "throw."

I have a very simple exception handler [1] that catches any exception in my
Camel route, and formats it appropriately for my application's protocol, and
sends it back through MinaConsumer's TCP connection.  It's been working
fine.  After reading the Message Router wiki page, I originally thought that
a .throwFault would be a good way to throw a message back out to my
exception handler-- but of course I soon saw that that is not the purpose of
.throwFault.

So then I started using this idiom for throwing exceptions:

when(header("cheese").regex(".*\\b(?i:process).*")).
  process(new MyThrower("insert better cheese, please"))

and it seems to work well.

[1]
http://www.nabble.com/Re%3A-Exception-handling%2C-for-InOut-exchanges--p20676917s22882.html

P.S. The FishEye link on the  http://camel.apache.org/source.html Source 
wiki page also isn't working.
-- 
View this message in context: http://www.nabble.com/throwFault-DSL-doesn%27t-actually-throw--tp21865262s22882p21969838.html
Sent from the Camel - Users mailing list archive at Nabble.com.