anchor.diff:      </doTry>
   </route>
   ----
  -
  -[[TryCatchFinally-Usingtry..catch..finallyinSpringDSL]]
  -== Using try .. catch .. finally in XML DSL
  -
  -In the route below we have all keywords in action. As the code is based
  -on a unit test we route using xref:components::mock-component.adoc[Mock].
  -
  -https://github.com/apache/camel/tree/main/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryProcessorMultipleExceptionTest.xml[SpringTryProcessorMultipleExceptionTest.xml]
  -
  -And finally we have an example of the `onWhen` predicate in action. We
  -can attach it to a `doCatch` block and at runtime determine if the block
  -should be triggered or not.
  -In our case we only want to trigger if the caused exception message
  -contains the *damn* word.
  -
  -https://github.com/apache/camel/tree/main/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryProcessorOnWhenTest.xml[SpringTryProcessorOnWhenTest.xml]
  -
  
positive.code: Then you may think that _docatch2_ is associated on the outer doTry because of how the code is formatted.
  But it is **not**, both __docatch1__ and __docatch2__ are in the inner doTry, and the outer doTry has no catch blocks.
  
  So in this example the route will throw the 1st exception which is then handled in __docatch1__ which
  then throw a 2nd exception, that is not caught.
  
  So what you must do is to end the doCatch block correct (notice how we use `doEndTry()` two times) as shown below:
  
  
negative.code: [[TryCatchFinally-TryCatchFinally]]
  = Try ... Catch ... Finally
  
  Camel supports the Java equivalent of try ... catch ... finally directly in the DSL.
  It aims to work like its Java sisters but with more power.
  
  In Camel we prefix the keywords with `do` to avoid having same keyword as Java.
  So we have:
  
  - `doTry`
  - `doCatch`
  - `doFinally`
  - `end` to end the block in Java DSL
  
  When using `doTry ... doCatch ... doFinally` then the regular Camel
  xref:error-handler.adoc[Error Handler] is not in use; meaning any
  `onException` or the likes does not trigger.
  The reason is that
  `doTry ... doCatch ... doFinally` is in fact its own error handler and mimics how try/catch/finally works in Java.
  
  == Using doTry ... doCatch ... doFinally
  
  In the route below we have all of them in action:
  
  [source,java]
  ----
  from("direct:start")
      .doTry()
          .process(new ProcessorFail())
          .to("mock:result")
      .doCatch(IOException.class, IllegalStateException.class)
          .to("mock:catch")
      .doFinally()
          .to("mock:finally")
      .end();
  ----
  
  And in XML DSL
  
  [source,xml]
  ----
  <route>
    <from uri="direct:start"/>
    <doTry>
      <process ref="processorFail"/>
      <to uri="mock:result"/>
      <doCatch>
        <exception>java.io.IOException</exception>
        <exception>java.lang.IllegalStateException</exception>
        <to uri="mock:catch"/>
      </doCatch>
      <doFinally>
         <to uri="mock:finally"/>
      </doFinally>
    </doTry>
  </route>
  ----
  
  === Using onWhen with doCatch
  
  You can use xref:predicate.adoc[Predicate]s with `doCatch` to make it runtime determine if the block should be triggered or not.
  In our case we only want to trigger if the caused exception message contains the *damn* word.
  
  [source,java]
  ----
  from("direct:start")
      .doTry()
          .process(new ProcessorFail())
          .to("mock:result")
      .doCatch(IOException.class, IllegalStateException.class).onWhen(exceptionMessage().contains("Damn"))
          .to("mock:catch")
      .doCatch(CamelExchangeException.class)
          .to("mock:catchCamel")
      .doFinally()
          .to("mock:finally")
      .end();
  ----
  
  And in XML DSL
  
  [source,xml]
  ----
  <route>
    <from uri="direct:start"/>
    <doTry>
      <process ref="processorFail"/>
      <to uri="mock:result"/>
      <doCatch>
        <exception>java.io.IOException</exception>
        <exception>java.lang.IllegalStateException</exception>
        <onWhen>
          <simple>${exception.message} contains 'Damn'</simple>
        </onWhen>
        <to uri="mock:catch"/>
      </doCatch>
      <doCatch>
        <exception>org.apache.camel.CamelExchangeException</exception>
        <to uri="mock:catchCamel"/>
      </doCatch>
      <doFinally>
         <to uri="mock:finally"/>
      </doFinally>
    </doTry>
  </route>
  ----
  
  === Use end() to end the block
  
  Notice when using Java DSL we must use `end()` to indicate where the try ... catch ... finally block ends.
  As the example above has a finally, then the `end()` should be at the end of the finally block.
  If we are not using a finally, then the `end()` should be at the end of the `doCatch`
  to indicate the end there.
  
  TIP: Instead of `end()` you can use `endDoTry()` to end and _return back_ to the try ... catch scope.
  
  === Using nested doTry ... doCatch EIPs
  
  When nesting doTry ... doCatch from an outer doTry ... doCatch EIP, then pay extra attention when using Java DSL as the Java programming language is not _indent aware_ so you may write Java code that are indented in a way where you think that a catch block is associated with the other doTry but it is not.
  
  Given the following Java DSL:
  
  