WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
Errors.hpp File Reference
#include <stdint.h>
#include <memory>
#include <stdexcept>
#include <string>
#include <fmt/format.h>
#include "wpi/system/WPIErrors.mac"
#include "wpi/system/WPIWarnings.mac"

Go to the source code of this file.

Classes

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

Namespaces

namespace  wpi
namespace  wpi::err
namespace  wpi::warn

Macros

#define S(label, offset, message)
#define S(label, offset, message)
#define WPILIB_ReportError(status, format, ...)
 Reports an error to the driver station (using HAL_SendError).
#define WPILIB_ReportWarning(format, ...)
 Reports a warning to the driver station (using HAL_SendError).
#define WPILIB_MakeError(status, format, ...)
 Makes a runtime error exception object.
#define WPILIB_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 WPILIB_AssertMessage(condition, format, ...)
#define WPILIB_Assert(condition)

Functions

const char * wpi::GetErrorMessage (int32_t *code)
 Gets error message string for an error code.
void wpi::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 wpi::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 wpi::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 wpi::MakeError (int32_t status, const char *fileName, int lineNumber, const char *funcName, fmt::string_view format, Args &&... args)
 wpi::err::S (ModuleIndexOutOfRange, -1, "Allocating module that is out of range or not found") S(ChannelIndexOutOfRange
Allocating channel that is out of range wpi::err::S (NotAllocated, -2, "Attempting to free unallocated resource") S(ResourceAlreadyAllocated
Allocating channel that is out of range Attempted to reuse an allocated resource wpi::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 wpi::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 wpi::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 wpi::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 wpi::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 wpi::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 wpi::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 wpi::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 wpi::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 wpi::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 wpi::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 wpi::err::S (SPIClockRateTooLow, -29, "SPI clock rate was below the minimum supported") 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 Error reading NetworkTables socket wpi::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 Error reading NetworkTables socket The wrong type was read from the NetworkTables entry wpi::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 Error reading NetworkTables socket The wrong type was read from the NetworkTables entry SmartDashboard data does not exist wpi::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 Error reading NetworkTables socket The wrong type was read from the NetworkTables entry SmartDashboard data does not exist Unsupported in simulation wpi::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 Error reading NetworkTables socket The wrong type was read from the NetworkTables entry SmartDashboard data does not exist Unsupported in simulation Invalid parameter value wpi::err::S (AssertionFailure, -110, "Assertion failed") S(Error
 wpi::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] wpi::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 wpi::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 wpi::err::dashboard

Macro Definition Documentation

◆ 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;

◆ WPILIB_Assert

#define WPILIB_Assert ( condition)
Value:
WPILIB_AssertMessage(condition, #condition)
#define WPILIB_AssertMessage(condition, format,...)
Definition Errors.hpp:186

◆ WPILIB_AssertMessage

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

◆ WPILIB_CheckErrorStatus

#define WPILIB_CheckErrorStatus ( status,
format,
... )
Value:
do { \
if ((status) < 0) { \
throw ::wpi::MakeError(status, __FILE__, __LINE__, __FUNCTION__, \
format __VA_OPT__(, ) __VA_ARGS__); \
} else if ((status) > 0) { \
::wpi::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

◆ WPILIB_MakeError

#define WPILIB_MakeError ( status,
format,
... )
Value:
::wpi::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.hpp: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

◆ WPILIB_ReportError

#define WPILIB_ReportError ( status,
format,
... )
Value:
do { \
if ((status) != 0) { \
::wpi::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

◆ WPILIB_ReportWarning

#define WPILIB_ReportWarning ( format,
... )
Value:
do { \
::wpi::ReportError(::wpi::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