[wpilibc] Remove ErrorBase (#3306)

Replace with new exception-based error reporting, consistent with Java.
This also builds stacktraces into the reporting/exceptions.
This commit is contained in:
Peter Johnson
2021-04-18 20:35:29 -07:00
committed by GitHub
parent 0abf6c9045
commit 8d961dfd25
113 changed files with 993 additions and 2200 deletions

View File

@@ -4,16 +4,15 @@
#include "frc/commands/CommandGroup.h"
#include "frc/WPIErrors.h"
#include "frc/Errors.h"
using namespace frc;
CommandGroup::CommandGroup(const wpi::Twine& name) : Command(name) {}
void CommandGroup::AddSequential(Command* command) {
if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
if (!command) {
throw FRC_MakeError(err::NullParameter, "command");
}
if (!AssertUnlocked("Cannot add new command to command group")) {
return;
@@ -31,16 +30,14 @@ void CommandGroup::AddSequential(Command* command) {
}
void CommandGroup::AddSequential(Command* command, double timeout) {
if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
if (!command) {
throw FRC_MakeError(err::NullParameter, "command");
}
if (!AssertUnlocked("Cannot add new command to command group")) {
return;
}
if (timeout < 0.0) {
wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0");
return;
throw FRC_MakeError(err::ParameterOutOfRange, "timeout < 0.0");
}
m_commands.emplace_back(command, CommandGroupEntry::kSequence_InSequence,
@@ -56,8 +53,8 @@ void CommandGroup::AddSequential(Command* command, double timeout) {
}
void CommandGroup::AddParallel(Command* command) {
if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
if (!command) {
throw FRC_MakeError(err::NullParameter, "command");
return;
}
if (!AssertUnlocked("Cannot add new command to command group")) {
@@ -76,16 +73,14 @@ void CommandGroup::AddParallel(Command* command) {
}
void CommandGroup::AddParallel(Command* command, double timeout) {
if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
if (!command) {
throw FRC_MakeError(err::NullParameter, "command");
}
if (!AssertUnlocked("Cannot add new command to command group")) {
return;
}
if (timeout < 0.0) {
wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0");
return;
throw FRC_MakeError(err::ParameterOutOfRange, "timeout < 0.0");
}
m_commands.emplace_back(command, CommandGroupEntry::kSequence_BranchChild,