WPILibC++  2020.3.2-60-g3011ebe
WPIErrors.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <stdint.h>
11 
12 #define S(label, offset, message) \
13  constexpr inline const char* wpi_error_s_##label() { return message; } \
14  constexpr inline int wpi_error_value_##label() { return offset; }
15 
16 // Fatal errors
17 S(ModuleIndexOutOfRange, -1,
18  "Allocating module that is out of range or not found")
19 S(ChannelIndexOutOfRange, -1, "Allocating channel that is out of range")
20 S(NotAllocated, -2, "Attempting to free unallocated resource")
21 S(ResourceAlreadyAllocated, -3, "Attempted to reuse an allocated resource")
22 S(NoAvailableResources, -4, "No available resources to allocate")
23 S(NullParameter, -5, "A pointer parameter to a method is nullptr")
24 S(Timeout, -6, "A timeout has been exceeded")
25 S(CompassManufacturerError, -7, "Compass manufacturer doesn't match HiTechnic")
26 S(CompassTypeError, -8,
27  "Compass type doesn't match expected type for HiTechnic compass")
28 S(IncompatibleMode, -9, "The object is in an incompatible mode")
29 S(AnalogTriggerLimitOrderError, -10,
30  "AnalogTrigger limits error. Lower limit > Upper Limit")
31 S(AnalogTriggerPulseOutputError, -11,
32  "Attempted to read AnalogTrigger pulse output.")
33 S(TaskError, -12, "Task can't be started")
34 S(TaskIDError, -13, "Task error: Invalid ID.")
35 S(TaskDeletedError, -14, "Task error: Task already deleted.")
36 S(TaskOptionsError, -15, "Task error: Invalid options.")
37 S(TaskMemoryError, -16, "Task can't be started due to insufficient memory.")
38 S(TaskPriorityError, -17, "Task error: Invalid priority [1-255].")
39 S(DriveUninitialized, -18, "RobotDrive not initialized for the C interface")
40 S(CompressorNonMatching, -19,
41  "Compressor slot/channel doesn't match previous instance")
42 S(CompressorAlreadyDefined, -20, "Creating a second compressor instance")
43 S(CompressorUndefined, -21,
44  "Using compressor functions without defining compressor")
45 S(InconsistentArrayValueAdded, -22,
46  "When packing data into an array to the dashboard, not all values added were "
47  "of the same type.")
48 S(MismatchedComplexTypeClose, -23,
49  "When packing data to the dashboard, a Close for a complex type was called "
50  "without a matching Open.")
51 S(DashboardDataOverflow, -24,
52  "When packing data to the dashboard, too much data was packed and the buffer "
53  "overflowed.")
54 S(DashboardDataCollision, -25,
55  "The same buffer was used for packing data and for printing.")
56 S(EnhancedIOMissing, -26, "IO is not attached or Enhanced IO is not enabled.")
57 S(LineNotOutput, -27,
58  "Cannot SetDigitalOutput for a line not configured for output.")
59 S(ParameterOutOfRange, -28, "A parameter is out of range.")
60 S(SPIClockRateTooLow, -29, "SPI clock rate was below the minimum supported")
61 S(JaguarVersionError, -30, "Jaguar firmware version error")
62 S(JaguarMessageNotFound, -31, "Jaguar message not found")
63 S(NetworkTablesReadError, -40, "Error reading NetworkTables socket")
64 S(NetworkTablesBufferFull, -41, "Buffer full writing to NetworkTables socket")
65 S(NetworkTablesWrongType, -42,
66  "The wrong type was read from the NetworkTables entry")
67 S(NetworkTablesCorrupt, -43, "NetworkTables data stream is corrupt")
68 S(SmartDashboardMissingKey, -43, "SmartDashboard data does not exist")
69 S(CommandIllegalUse, -50, "Illegal use of Command")
70 S(UnsupportedInSimulation, -80, "Unsupported in simulation")
71 S(CameraServerError, -90, "CameraServer error")
72 S(InvalidParameter, -100, "Invalid parameter value")
73 
74 // Warnings
75 S(SampleRateTooHigh, 1, "Analog module sample rate is too high")
76 S(VoltageOutOfRange, 2,
77  "Voltage to convert to raw value is out of range [-10; 10]")
78 S(CompressorTaskError, 3, "Compressor task won't start")
79 S(LoopTimingError, 4, "Digital module loop timing is not the expected value")
80 S(NonBinaryDigitalValue, 5, "Digital output value is not 0 or 1")
81 S(IncorrectBatteryChannel, 6,
82  "Battery measurement channel is not correct value")
83 S(BadJoystickIndex, 7, "Joystick index is out of range, should be 0-3")
84 S(BadJoystickAxis, 8, "Joystick axis or POV is out of range")
85 S(InvalidMotorIndex, 9, "Motor index is out of range, should be 0-3")
86 S(DriverStationTaskError, 10, "Driver Station task won't start")
87 S(EnhancedIOPWMPeriodOutOfRange, 11,
88  "Driver Station Enhanced IO PWM Output period out of range.")
89 S(SPIWriteNoMOSI, 12, "Cannot write to SPI port with no MOSI output")
90 S(SPIReadNoMISO, 13, "Cannot read from SPI port with no MISO input")
91 S(SPIReadNoData, 14, "No data available to read from SPI")
92 S(IncompatibleState, 15,
93  "Incompatible State: The operation cannot be completed")
94 
95 #undef S