4 Replies Latest reply on Sep 29, 2011 11:38 PM by Jason Porter

    What does it mean that Seam Catch marks an exception as handled.

    Adam Victor Brandizzi Newbie

      The Seam Catch reference guide states that exceptions can be mark as handled.



      abort() - terminate all handling immediately after this handler, does not mark the exception as handled, does not re-throw the exception.


      handled() - marks the exception as handled and terminates further handling.


      markHandled() - default. Marks the exception as handled and proceeds with the rest of the handlers.

      I wonder: what does it mean that an exception is marked as handled? Will it not be re-thrown? If it is the case, then what is the sense of abort not marking the exception as thrown neither re-throwing it?

        • 1. Re: What does it mean that Seam Catch marks an exception as handled.
          Adam Victor Brandizzi Newbie

          I suspect my question looks a bit confusing. It makes sense because I am very confused myself :) Anyway, I bet there is a more straightforward question that can help me to put some light in my doubts:



          What is the difference between CaughtException.abort() and CaughtException.handled()? If I call CaughtException.abort(), what will happen that would not occur if I have called CaughtException.handled()?
          • 2. Re: What does it mean that Seam Catch marks an exception as handled.
            Jason Porter Master

            • abort(): An exception may or may not have gone through other handlers once an abort has been issued. Abort stops Catch from processing the exception any further and the exception is not marked as being handled. Processing will pick back up from the point were the event was fired and it is strongly recommended that the integration with Catch (your application or some other Seam module) check to see if it was handled. If the exception was not handled (it's a boolean flag) that exception should be thrown.

            • handled(): Means Catch has done it's job and no further exception handlers are desired for the particular exception. This marks the exception as handled so when the integration checks that flag it will return true.

            • markHandled(): This is the default and doesn't need to be invoked. It marks the exception as handled and continues on with any exception handlers in the chain.



            Does that help at all?

            • 3. Re: What does it mean that Seam Catch marks an exception as handled.
              Adam Victor Brandizzi Newbie

              Jason Porter wrote on Sep 29, 2011 17:20:

              Does that help at all?


              Yes! Let me see if if I understood it well. Could I say the difference between abort() and handled() is that handled() sets the handled flag of ExceptionToCatch? And should this flag be always verified after the processing of Seam Catch? I have not seen anything about it in the reference guide or in any other documentation, so I am trying to clarify this...


              Also, a more philosophical question: why does abort() does not re-throw the exception itself?


              Anyway, thank you for your very helpful answer and thanks in advance for possible future clarifications :P

              • 4. Re: What does it mean that Seam Catch marks an exception as handled.
                Jason Porter Master

                Yep, you've got it.


                They're different because they serve different purposes. There's also a rethrow() and rethrow(Throwable) if you would like to rethrow the exception or a different one. abort() is essentially saying I've acknowledged an exception has occurred, but I can't or don't want to do anything with it. They are a little different. They idea of Catch is to give developers all the power to do what they'd want to do with exceptions.


                Sorry for the poor docs, could you please add a JIRA to the Catch JIRA for an enhancement?