oshai oshai - 1 month ago 7
Java Question

Can I set eclipse to show a warning if RuntimeException is not handled?

I have the following code:

public static void main(String[] args)
{
willItThrowException();
}

private static void willItThrowException() throws RuntimeException
{
throw new RuntimeException();
}


Is there any configuration of eclipse that can show a warning/error on uncaught runtime exception that is declared in method declaration but not catched in line of
willItThrowException();
?

Answer

Not that I'm aware of, and I can't find one. Catching runtime exceptions is not always a good choice though. And you will get tons of warnings about catching IllegalArgumentException and NullPointerException. Runtime exceptions are usually meant not to be recoverable from.