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