Skip to content

Commit d27ac2d

Browse files
committed
[wpilibj] Fix incorrect robot name in reported error
1 parent 9e85f3c commit d27ac2d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,11 @@ private static <T extends RobotBase> void runRobot(Supplier<T> robotSupplier) {
382382
}
383383
String robotName = "Unknown";
384384
StackTraceElement[] elements = throwable.getStackTrace();
385-
if (elements.length > 0) {
386-
robotName = elements[0].getClassName();
385+
for (var element : elements) {
386+
if (RobotBase.class.isAssignableFrom(Class.forName(element.getClassName()))) {
387+
robotName = element.getClassName();
388+
break;
389+
}
387390
}
388391
DriverStation.reportError(
389392
"Unhandled exception instantiating robot " + robotName + " " + throwable, elements);

0 commit comments

Comments
 (0)