Permalink
Browse files

warn about UndeclaredThrowableException in log

If a manager method throws an Exception that its corresponding interface does not declare this Exception will be thrown. Now a warning about it will be printed to the log making it easier to debug. The main reason this can be a problem is because the BioclipseException is a checked exception (which keeps on biting us). Now if a manager interface author forgets to write "throws BioclipseException" where needed at least a warning is written to the log when the code is run.
  • Loading branch information...
1 parent 7d4994d commit 684b052c022e06d0848ba1f9461c99d7ebd71280 @jonalv jonalv committed Apr 13, 2012
@@ -35,6 +35,7 @@
import net.bioclipse.scripting.JsAction;
import net.bioclipse.scripting.JsThread;
+import org.apache.log4j.Logger;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.browser.IWebBrowser;
@@ -47,6 +48,7 @@
private static JsThread jsThread = Activator.getDefault().JS_THREAD;
private static Pattern p
= Pattern.compile( " Wrapped (\\S+): (.*?) \\(<Unknown source>#" );
+ private static Logger logger = Logger.getLogger( JsConsoleView.class );
@Override
protected String executeCommand( String command ) {
@@ -199,6 +201,13 @@ public String getErrorMessage(Throwable t) {
return exceptionType + ": " + causeMessage;
}
}
+ if ( message.contains(
+ "java.lang.reflect.UndeclaredThrowableException" ) ) {
+ logger.warn( "java.lang.reflect.UndeclaredThrowableException " +
+ "found. This could be because a manager method throws an " +
+ "Exception e.g. BioclipseException without declaring it in " +
+ "the called method on it's interface" );
+ }
return t.getMessage();
// This used to work back in the days, if you think back in the days are

0 comments on commit 684b052

Please sign in to comment.