diff --git a/wpilibc/src/main/native/cpp/MotorSafety.cpp b/wpilibc/src/main/native/cpp/MotorSafety.cpp index 91b4dfb328..388a887a97 100644 --- a/wpilibc/src/main/native/cpp/MotorSafety.cpp +++ b/wpilibc/src/main/native/cpp/MotorSafety.cpp @@ -98,7 +98,15 @@ void MotorSafety::Check() { if (stopTime < Timer::GetFPGATimestamp()) { FRC_ReportError(err::Timeout, "{}... Output not updated often enough", GetDescription()); - StopMotor(); + + try { + StopMotor(); + } catch (frc::RuntimeError& e) { + e.Report(); + } catch (std::exception& e) { + FRC_ReportError(err::Error, "{} StopMotor threw unexpected exception: {}", + GetDescription(), e.what()); + } } } diff --git a/wpilibc/src/main/native/include/frc/MotorSafety.h b/wpilibc/src/main/native/include/frc/MotorSafety.h index f84af1796f..1bfd34a81a 100644 --- a/wpilibc/src/main/native/include/frc/MotorSafety.h +++ b/wpilibc/src/main/native/include/frc/MotorSafety.h @@ -91,6 +91,12 @@ class MotorSafety { static void CheckMotors(); virtual void StopMotor() = 0; + + /** + * The return value from this method is printed out when an error occurs + * + * This method must not throw! + */ virtual std::string GetDescription() const = 0; private: