Of course, the ideal fix is to add unit tests that ensure that exceptions
are thrown when they ought to be.
Keith
On Jan 22, 2008 11:47 AM, Adam Monsen <[EMAIL PROTECTED]> wrote:
> I was recently puzzled why MenuParser.isMenuItemVisible() wasn't
> throwing a SystemException when it seemed like it should be. I knew
> that Method.invoke() should fail, so I was looking to see that a
> NoSuchMethodException was thrown.
>
> The debugger revealed Method.invoke() was indeed throwing a
> NoSuchMethodException, but take a look at the corresponding "catch"
> block:
>
> catch (NoSuchMethodException nsme) {
> new MenuParseException(nsme);
> }
>
> What's missing?
>
> Something critical. I so expected to see it there that I just scanned
> right passed it. It's also something that neither Eclipse nor the Java
> compiler will nag about (by default, at least).
>
> Hopefully something like findbugs, checkstyle, or pmd will help us
> find similar mistakes. Or if someone knows a way to get javac or
> Eclipse to nag about this, do tell.
>
> And of course by now you've figured out that a "throw" statement was
> missing. The code should read:
>
> catch (NoSuchMethodException nsme) {
> throw new MenuParseException(nsme);
> }
>
> --
> Adam Monsen
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/