mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user