From 0b950ea6d9b9c9955a89d0a2b58ae2fc2db5ad24 Mon Sep 17 00:00:00 2001 From: Thad House Date: Fri, 19 Jun 2026 14:51:46 -0700 Subject: [PATCH] [wpilibj] Crash robot program if an exception occurs during opmode construction (#8982) There's essentially nothing the user can do here, other then switch opmodes. It will make it clearer that something is very wrong. --- wpilibj/src/main/java/org/wpilib/framework/OpModeRobot.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wpilibj/src/main/java/org/wpilib/framework/OpModeRobot.java b/wpilibj/src/main/java/org/wpilib/framework/OpModeRobot.java index b691469a70..033d64e6c0 100644 --- a/wpilibj/src/main/java/org/wpilib/framework/OpModeRobot.java +++ b/wpilibj/src/main/java/org/wpilib/framework/OpModeRobot.java @@ -118,9 +118,8 @@ public abstract class OpModeRobot extends RobotBase { try { return constructor.get().newInstance(this); } catch (ReflectiveOperationException e) { - DriverStationErrors.reportError( - "Could not instantiate OpMode " + cls.getSimpleName(), e.getStackTrace()); - return null; + throw new RuntimeException( + "Could not instantiate OpMode " + cls.getSimpleName(), e.getCause()); } }