WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
Errors.h File Reference
#include <stdint.h>
#include <memory>
#include <stdexcept>
#include <string>
#include <fmt/format.h>
#include "frc/WPIErrors.mac"
#include "frc/WPIWarnings.mac"

Go to the source code of this file.

Classes

class  frc::RuntimeError
 Runtime error exception. More...
 

Namespaces

namespace  frc
 
namespace  frc::err
 
namespace  frc::warn
 

Macros

#define S(label, offset, message)
 
#define S(label, offset, message)
 
#define FRC_ReportError(status, format, ...)
 Reports an error to the driver station (using HAL_SendError).
 
#define FRC_ReportWarning(format, ...)
 Reports a warning to the driver station (using HAL_SendError).
 
#define FRC_MakeError(status, format, ...)
 Makes a runtime error exception object.
 
#define FRC_CheckErrorStatus(status, format, ...)
 Checks a status code and depending on its value, either throws a RuntimeError exception, calls ReportError, or does nothing (if no error).
 
#define FRC_AssertMessage(condition, format, ...)
 
#define FRC_Assert(condition)
 

Functions

const char * frc::GetErrorMessage (int32_t *code)
 Gets error message string for an error code.
 
void frc::ReportErrorV (int32_t status, const char *fileName, int lineNumber, const char *funcName, fmt::string_view format, fmt::format_args args)
 Reports an error to the driver station (using HAL_SendError).
 
template<typename... Args>
void frc::ReportError (int32_t status, const char *fileName, int lineNumber, const char *funcName, fmt::string_view format, Args &&... args)
 Reports an error to the driver station (using HAL_SendError).
 
RuntimeError frc::MakeErrorV (int32_t status, const char *fileName, int lineNumber, const char *funcName, fmt::string_view format, fmt::format_args args)
 Makes a runtime error exception object.
 
template<typename... Args>
RuntimeError frc::MakeError (int32_t status, const char *fileName, int lineNumber, const char *funcName, fmt::string_view format, Args &&... args)
 
 frc::err::S (ModuleIndexOutOfRange, -1, "Allocating module that is out of range or not found") S(ChannelIndexOutOfRange
 
Allocating channel that is out of range frc::err::S (NotAllocated, -2, "Attempting to free unallocated resource") S(ResourceAlreadyAllocated
 
Allocating channel that is out of range Attempted to reuse an allocated resource frc::err::S (NoAvailableResources, -4, "No available resources to allocate") S(NullParameter
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr frc::err::S (Timeout, -6, "A timeout has been exceeded") S(CompassManufacturerError
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic frc::err::S (CompassTypeError, -8, "Compass type doesn't match expected type for HiTechnic compass") S(IncompatibleMode
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode frc::err::S (AnalogTriggerLimitOrderError, -10, "AnalogTrigger limits error. Lower limit > Upper Limit") S(AnalogTriggerPulseOutputError
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output frc::err::S (TaskError, -12, "Task can't be started") S(TaskIDError
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory frc::err::S (TaskPriorityError, -17, "Task error: Invalid priority [1-255]") S(DriveUninitialized
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface frc::err::S (CompressorNonMatching, -19, "Compressor slot/channel doesn't match previous instance") S(CompressorAlreadyDefined
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance frc::err::S (CompressorUndefined, -21, "Using compressor functions without defining compressor") S(InconsistentArrayValueAdded
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance When packing data into an array to the not all values added were of the same type frc::err::S (MismatchedComplexTypeClose, -23, "When packing data to the dashboard, a Close for a complex type was called " "without a matching Open") S(DashboardDataOverflow
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance When packing data into an array to the not all values added were of the same type When packing data to the too much data was packed and the buffer overflowed frc::err::S (DashboardDataCollision, -25, "The same buffer was used for packing data and for printing") S(EnhancedIOMissing
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance When packing data into an array to the not all values added were of the same type When packing data to the too much data was packed and the buffer overflowed IO is not attached or Enhanced IO is not enabled frc::err::S (LineNotOutput, -27, "Cannot SetDigitalOutput for a line not configured for output") S(ParameterOutOfRange
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance When packing data into an array to the not all values added were of the same type When packing data to the too much data was packed and the buffer overflowed IO is not attached or Enhanced IO is not enabled A parameter is out of range frc::err::S (SPIClockRateTooLow, -29, "SPI clock rate was below the minimum supported") S(JaguarVersionError
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance When packing data into an array to the not all values added were of the same type When packing data to the too much data was packed and the buffer overflowed IO is not attached or Enhanced IO is not enabled A parameter is out of range Jaguar firmware version error frc::err::S (JaguarMessageNotFound, -31, "Jaguar message not found") S(NetworkTablesReadError
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance When packing data into an array to the not all values added were of the same type When packing data to the too much data was packed and the buffer overflowed IO is not attached or Enhanced IO is not enabled A parameter is out of range Jaguar firmware version error Error reading NetworkTables socket frc::err::S (NetworkTablesBufferFull, -41, "Buffer full writing to NetworkTables socket") S(NetworkTablesWrongType
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance When packing data into an array to the not all values added were of the same type When packing data to the too much data was packed and the buffer overflowed IO is not attached or Enhanced IO is not enabled A parameter is out of range Jaguar firmware version error Error reading NetworkTables socket The wrong type was read from the NetworkTables entry frc::err::S (NetworkTablesCorrupt, -43, "NetworkTables data stream is corrupt") S(SmartDashboardMissingKey
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance When packing data into an array to the not all values added were of the same type When packing data to the too much data was packed and the buffer overflowed IO is not attached or Enhanced IO is not enabled A parameter is out of range Jaguar firmware version error Error reading NetworkTables socket The wrong type was read from the NetworkTables entry SmartDashboard data does not exist frc::err::S (CommandIllegalUse, -50, "Illegal use of Command") S(UnsupportedInSimulation
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance When packing data into an array to the not all values added were of the same type When packing data to the too much data was packed and the buffer overflowed IO is not attached or Enhanced IO is not enabled A parameter is out of range Jaguar firmware version error Error reading NetworkTables socket The wrong type was read from the NetworkTables entry SmartDashboard data does not exist Unsupported in simulation frc::err::S (CameraServerError, -90, "CameraServer error") S(InvalidParameter
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance When packing data into an array to the not all values added were of the same type When packing data to the too much data was packed and the buffer overflowed IO is not attached or Enhanced IO is not enabled A parameter is out of range Jaguar firmware version error Error reading NetworkTables socket The wrong type was read from the NetworkTables entry SmartDashboard data does not exist Unsupported in simulation Invalid parameter value frc::err::S (AssertionFailure, -110, "Assertion failed") S(Error
 
 frc::warn::S (SampleRateTooHigh, 1, "Analog module sample rate is too high") S(VoltageOutOfRange
 
Voltage to convert to raw value is out of range[-10;10] frc::warn::S (CompressorTaskError, 3, "Compressor task won't start") S(LoopTimingError
 

Variables

Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task frc::err::error
 
Allocating channel that is out of range Attempted to reuse an allocated resource A pointer parameter to a method is nullptr Compass manufacturer doesn t match HiTechnic The object is in an incompatible mode Attempted to read AnalogTrigger pulse output Task Task Task Task can t be started due to insufficient memory RobotDrive not initialized for the C interface Creating a second compressor instance When packing data into an array to the frc::err::dashboard
 

Macro Definition Documentation

◆ FRC_Assert

#define FRC_Assert ( condition)
Value:
FRC_AssertMessage(condition, #condition)
#define FRC_AssertMessage(condition, format,...)
Definition Errors.h:186

◆ FRC_AssertMessage

#define FRC_AssertMessage ( condition,
format,
... )
Value:
do { \
if (!(condition)) { \
throw ::frc::MakeError(::frc::err::AssertionFailure, __FILE__, __LINE__, \
__FUNCTION__, format __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
FMT_INLINE auto format(detail::locale_ref loc, format_string< T... > fmt, T &&... args) -> std::string
Definition format.h:4146

◆ FRC_CheckErrorStatus

#define FRC_CheckErrorStatus ( status,
format,
... )
Value:
do { \
if ((status) < 0) { \
throw ::frc::MakeError(status, __FILE__, __LINE__, __FUNCTION__, \
format __VA_OPT__(, ) __VA_ARGS__); \
} else if ((status) > 0) { \
::frc::ReportError(status, __FILE__, __LINE__, __FUNCTION__, \
format __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)

Checks a status code and depending on its value, either throws a RuntimeError exception, calls ReportError, or does nothing (if no error).

Parameters
[out]statuserror code
[in]formaterror message format

◆ FRC_MakeError

#define FRC_MakeError ( status,
format,
... )
Value:
::frc::MakeError(status, __FILE__, __LINE__, __FUNCTION__, \
format __VA_OPT__(, ) __VA_ARGS__)
RuntimeError MakeError(int32_t status, const char *fileName, int lineNumber, const char *funcName, fmt::string_view format, Args &&... args)
Definition Errors.h:105

Makes a runtime error exception object.

This object should be thrown by the caller.

Parameters
[out]statuserror code
[in]formaterror message format
Returns
runtime error object

◆ FRC_ReportError

#define FRC_ReportError ( status,
format,
... )
Value:
do { \
if ((status) != 0) { \
::frc::ReportError(status, __FILE__, __LINE__, __FUNCTION__, \
format __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)

Reports an error to the driver station (using HAL_SendError).

Parameters
[out]statuserror code
[in]formaterror message format

◆ FRC_ReportWarning

#define FRC_ReportWarning ( format,
... )
Value:
do { \
::frc::ReportError(::frc::warn::Warning, __FILE__, __LINE__, __FUNCTION__, \
format __VA_OPT__(, ) __VA_ARGS__); \
} while (0)

Reports a warning to the driver station (using HAL_SendError).

Parameters
[in]formaterror message format

◆ S [1/2]

#define S ( label,
offset,
message )
Value:
inline constexpr int label = offset;

◆ S [2/2]

#define S ( label,
offset,
message )
Value:
inline constexpr int label = offset;