You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by fmaylinch <fe...@gmail.com> on 2012/11/19 10:59:43 UTC
MethodInvocation.didThrowCheckedException returns true when there
is a RuntimeException
Hello,
We implemented a method advisor to handle transactions and found that the
method *MethodInvocation.didThrowCheckedException* returns true when the
advised method throws a *RuntimeException*. Is this the expected behaviour?
Since we didn't expect that, we did this workaround:
private class TransactionMethodAdvice implements MethodAdvice
{
@Override
public void advise(MethodInvocation invocation)
{
...
if (invocation.didThrowCheckedException())
{
// TODO: Tapestry bug??
final RuntimeException rtEx =
invocation.getCheckedException(RuntimeException.class);
if (rtEx != null)
throw rtEx;
else
invocation.rethrow();
}
...
}
}
--
View this message in context: http://tapestry.1045711.n5.nabble.com/MethodInvocation-didThrowCheckedException-returns-true-when-there-is-a-RuntimeException-tp5718086.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MethodInvocation.didThrowCheckedException returns true when there
is a RuntimeException
Posted by Howard Lewis Ship <hl...@gmail.com>.
Ill have to take a peek at the javadoc and tests to see what's up.
On Monday, November 19, 2012, fmaylinch wrote:
> My advised method throws an exception that (indirectly) extends
> RuntimeException. And I don't catch it -- not before getting to the
> advisor. I catch it afterwards, and that's when I noticed the wrapped
> exception (wrapped by "rethrow").
>
> I debugged the code and I get to the line where it says "throw rtEx;". Is
> that even possible? I am asking for a RuntimeException exception and I get
> one. I should always get "null", shouldn't I.
>
> Thanks for your help.
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/MethodInvocation-didThrowCheckedException-returns-true-when-there-is-a-RuntimeException-tp5718086p5718118.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
--
Howard M. Lewis Ship
Creator of Apache Tapestry
The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!
(971) 678-5210
http://howardlewisship.com
Re: MethodInvocation.didThrowCheckedException returns true when
there is a RuntimeException
Posted by fmaylinch <fe...@gmail.com>.
My advised method throws an exception that (indirectly) extends
RuntimeException. And I don't catch it -- not before getting to the
advisor. I catch it afterwards, and that's when I noticed the wrapped
exception (wrapped by "rethrow").
I debugged the code and I get to the line where it says "throw rtEx;". Is
that even possible? I am asking for a RuntimeException exception and I get
one. I should always get "null", shouldn't I.
Thanks for your help.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/MethodInvocation-didThrowCheckedException-returns-true-when-there-is-a-RuntimeException-tp5718086p5718118.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
Re: MethodInvocation.didThrowCheckedException returns true when there
is a RuntimeException
Posted by Howard Lewis Ship <hl...@gmail.com>.
RuntimeExceptions are supposed to pass through; they are not caught by the
MethodInvocation. Checked exceptions are caught, and turn on the
didThrowCheckedException flag. Is it possible that the exception you threw
was caught and rethrown as a checked exception?
On Mon, Nov 19, 2012 at 1:59 AM, fmaylinch <fe...@gmail.com> wrote:
> Hello,
>
> We implemented a method advisor to handle transactions and found that the
> method *MethodInvocation.didThrowCheckedException* returns true when the
> advised method throws a *RuntimeException*. Is this the expected behaviour?
>
> Since we didn't expect that, we did this workaround:
>
> private class TransactionMethodAdvice implements MethodAdvice
> {
> @Override
> public void advise(MethodInvocation invocation)
> {
> ...
>
> if (invocation.didThrowCheckedException())
> {
> // TODO: Tapestry bug??
> final RuntimeException rtEx =
>
> invocation.getCheckedException(RuntimeException.class);
> if (rtEx != null)
> throw rtEx;
> else
> invocation.rethrow();
> }
>
> ...
> }
> }
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/MethodInvocation-didThrowCheckedException-returns-true-when-there-is-a-RuntimeException-tp5718086.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Howard M. Lewis Ship
Creator of Apache Tapestry
The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!
(971) 678-5210
http://howardlewisship.com