12 #include <wpi/StringRef.h>
13 #include <wpi/Twine.h>
14 #include <wpi/mutex.h>
17 #include "frc/Error.h"
22 #define wpi_setErrnoErrorWithContext(context) \
23 this->SetErrnoError((context), __FILE__, __FUNCTION__, __LINE__)
24 #define wpi_setErrnoError() wpi_setErrnoErrorWithContext("")
25 #define wpi_setImaqErrorWithContext(code, context) \
28 this->SetImaqError((code), (context), __FILE__, __FUNCTION__, __LINE__); \
30 #define wpi_setErrorWithContext(code, context) \
33 this->SetError((code), (context), __FILE__, __FUNCTION__, __LINE__); \
35 #define wpi_setErrorWithContextRange(code, min, max, req, context) \
38 this->SetErrorRange((code), (min), (max), (req), (context), __FILE__, \
39 __FUNCTION__, __LINE__); \
42 #define wpi_setHALError(code) \
45 this->SetError((code), HAL_GetErrorMessage(code), __FILE__, \
46 __FUNCTION__, __LINE__); \
49 #define wpi_setHALErrorWithRange(code, min, max, req) \
52 this->SetErrorRange((code), (min), (max), (req), \
53 HAL_GetErrorMessage(code), __FILE__, __FUNCTION__, \
57 #define wpi_setError(code) wpi_setErrorWithContext(code, "")
58 #define wpi_setStaticErrorWithContext(object, code, context) \
61 object->SetError((code), (context), __FILE__, __FUNCTION__, __LINE__); \
63 #define wpi_setStaticError(object, code) \
64 wpi_setStaticErrorWithContext(object, code, "")
66 #define wpi_setGlobalErrorWithContext(code, context) \
69 ::frc::ErrorBase::SetGlobalError((code), (context), __FILE__, \
70 __FUNCTION__, __LINE__); \
73 #define wpi_setGlobalHALError(code) \
76 ::frc::ErrorBase::SetGlobalError((code), HAL_GetErrorMessage(code), \
77 __FILE__, __FUNCTION__, __LINE__); \
80 #define wpi_setGlobalError(code) wpi_setGlobalErrorWithContext(code, "")
81 #define wpi_setWPIErrorWithContext(error, context) \
82 this->SetWPIError(wpi_error_s_##error(), wpi_error_value_##error(), \
83 (context), __FILE__, __FUNCTION__, __LINE__)
84 #define wpi_setWPIError(error) (wpi_setWPIErrorWithContext(error, ""))
85 #define wpi_setStaticWPIErrorWithContext(object, error, context) \
86 object->SetWPIError(wpi_error_s_##error(), (context), __FILE__, \
87 __FUNCTION__, __LINE__)
88 #define wpi_setStaticWPIError(object, error) \
89 wpi_setStaticWPIErrorWithContext(object, error, "")
90 #define wpi_setGlobalWPIErrorWithContext(error, context) \
91 ::frc::ErrorBase::SetGlobalWPIError(wpi_error_s_##error(), (context), \
92 __FILE__, __FUNCTION__, __LINE__)
93 #define wpi_setGlobalWPIError(error) wpi_setGlobalWPIErrorWithContext(error, "")
145 int lineNumber)
const;
159 int lineNumber)
const;
172 int lineNumber)
const;
187 virtual void SetErrorRange(Error::Code code, int32_t minRange,
188 int32_t maxRange, int32_t requestedValue,
191 int lineNumber)
const;
205 int lineNumber)
const;
207 virtual void CloneError(
const ErrorBase& rhs)
const;
216 static void SetGlobalError(Error::Code code,
const wpi::Twine& contextMessage,
220 static void SetGlobalWPIError(
const wpi::Twine& errorMessage,
241 mutable Error m_error;
virtual void SetErrorRange(Error::Code code, int32_t minRange, int32_t maxRange, int32_t requestedValue, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
Set the current error information associated with this sensor.
virtual Error & GetError()
Retrieve the current error.
virtual void SetWPIError(const wpi::Twine &errorMessage, Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
Set the current error information associated with this sensor.
void ClearGlobalErrors()
Clear global errors.
Base class for most objects.
Definition: ErrorBase.h:104
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
virtual void SetError(Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
Set the current error information associated with this sensor.
virtual void ClearError() const
Clear the current error information associated with this sensor.
Error object represents a library error.
Definition: Error.h:31
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
static std::vector< Error > GetGlobalErrors()
Retrieve all global errors.
virtual void SetImaqError(int success, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
Set the current error information associated from the nivision Imaq API.
virtual void SetErrnoError(const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
Set error information associated with a C library call that set an error to the "errno" global variab...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:85
const char * HAL_GetErrorMessage(int32_t code)
Gets the error message for a specific status code.
virtual bool StatusIsFatal() const
Check if the current error code represents a fatal error.
static Error GetGlobalError()
Retrieve the last global error.