Hello,

I need to use nested catch-blocks in my project like the following:

from("direct:start")                                            
.doTry()
        .setBody(simple("doTry"))
        .to("stream:out")                                       
.doCatch(Exception.class)
        .setBody(simple("doCatch"))
        .to("stream:out")                       
        .doTry()
                .setBody(simple("doTry in doCatch"))
                .to("stream:out")
        .doCatch(Exception.class)
                .setBody(simple("doCatch in doCatch"))
                .to("stream:out")
        .end()                                                                  
                        
.doFinally()
        .setBody(simple("doFinally"))
        .to("stream:out")                       
        .doTry()
                .setBody(simple("doTry in doFinally"))
                .to("stream:out")
        .doCatch(Exception.class)
                .setBody(simple("doCatch in doFinally"))
                .to("stream:out")                                       
        .end()                                  
        .stop()                                                 
.endDoTry();


Compiler says: the method doFinally() is undefined for the type
ProcessorDefinition<capture#1-of ?> so Eclipse suggests  ("add cast to
method receiver") following:



((TryDefinition) from("direct:start")                                           
.doTry()
        .setBody(simple("doTry"))
        .to("stream:out")                                       
.doCatch(Exception.class)
        .setBody(simple("doCatch"))
        .to("stream:out")                       
        .doTry()
                .setBody(simple("doTry in doCatch"))
                .to("stream:out")
        .doCatch(Exception.class)
                .setBody(simple("doCatch in doCatch"))
                .to("stream:out")
        .end()
        )                                                                       
                        
.doFinally()
        .setBody(simple("doFinally"))
        .to("stream:out")                       
        .doTry()
                .setBody(simple("doTry in doFinally"))
                .to("stream:out")
        .doCatch(Exception.class)
                .setBody(simple("doCatch in doFinally"))
                .to("stream:out")                                       
        .end()                                  
        .stop()                                                 
.endDoTry();


but then at runtime I get:

java.lang.ClassCastException: org.apache.camel.model.CatchDefinition cannot
be cast to org.apache.camel.model.TryDefinition


        Whats wrong here, I can't see a syntax error ? Is it a bug ?
        
                thanks for any advice
                
                        james



--
View this message in context: 
http://camel.465427.n5.nabble.com/nested-catch-blocks-in-doCatch-and-doFinally-tp5752429.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to