From efa28125c6d971edcb2aae16ccfe320e383f99cb Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Thu, 17 Jun 2021 23:52:48 -0700 Subject: [PATCH] [wpilibc] Add message to RobotBase on how to read stacktrace (#3444) Also make stacktrace info an error instead of a warning in both C++ and Java. --- wpilibc/src/main/native/include/frc/RobotBase.h | 12 ++++++++++-- .../main/java/edu/wpi/first/wpilibj/RobotBase.java | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/wpilibc/src/main/native/include/frc/RobotBase.h b/wpilibc/src/main/native/include/frc/RobotBase.h index cb67b58b28..e3a366cbdf 100644 --- a/wpilibc/src/main/native/include/frc/RobotBase.h +++ b/wpilibc/src/main/native/include/frc/RobotBase.h @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -16,8 +17,6 @@ namespace frc { -class DriverStation; - int RunHALInitialization(); namespace impl { @@ -33,6 +32,15 @@ void RunRobot(wpi::mutex& m, Robot** robot) { theRobot.StartCompetition(); } catch (const frc::RuntimeError& e) { e.Report(); + FRC_ReportError( + err::Error, "{}", + "The robot program quit unexpectedly." + " This is usually due to a code error.\n" + " The above stacktrace can help determine where the error occurred.\n" + " See https://wpilib.org/stacktrace for more information.\n"); + throw; + } catch (const std::exception& e) { + HAL_SendError(1, err::Error, 0, e.what(), "", "", 1); throw; } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java index b798746aa7..e41dfe41b4 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java @@ -300,7 +300,7 @@ public abstract class RobotBase implements AutoCloseable { DriverStation.reportError( "Unhandled exception instantiating robot " + robotName + " " + throwable.toString(), elements); - DriverStation.reportWarning( + DriverStation.reportError( "The robot program quit unexpectedly." + " This is usually due to a code error.\n" + " The above stacktrace can help determine where the error occurred.\n"