Fixed TimedRobot.java hanging if an exception was thrown (#926)

This commit is contained in:
Tyler Veness
2018-02-04 22:38:19 -08:00
committed by Peter Johnson
parent f720cbb121
commit 67f9c9a5b3

View File

@@ -99,6 +99,18 @@ public class Notifier {
}
});
m_thread.setDaemon(true);
m_thread.setUncaughtExceptionHandler((thread, error) -> {
Throwable cause = error.getCause();
if (cause != null) {
error = cause;
}
DriverStation.reportError("Unhandled exception: " + error.toString(), error.getStackTrace());
DriverStation.reportWarning("Robots should not quit, but yours did!", false);
DriverStation.reportError(
"The loopFunc() method (or methods called by it) should have handled "
+ "the exception above.", false);
System.exit(1);
});
m_thread.start();
}