Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame] | 2 | /* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 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 | |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
| 12 | #include <wpi/StringRef.h> |
| 13 | #include <wpi/Twine.h> |
| 14 | #include <wpi/mutex.h> |
| 15 | |
| 16 | // Forward declared manually to avoid needing to pull in entire HAL header. |
| 17 | extern "C" const char* HAL_GetErrorMessage(int32_t code); |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 18 | |
| 19 | #define wpi_setErrnoErrorWithContext(context) \ |
| 20 | this->SetErrnoError((context), __FILE__, __FUNCTION__, __LINE__) |
| 21 | #define wpi_setErrnoError() wpi_setErrnoErrorWithContext("") |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame] | 22 | #define wpi_setImaqErrorWithContext(code, context) \ |
| 23 | do { \ |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 24 | } while (0) |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame] | 25 | #define wpi_setErrorWithContext(code, context) \ |
| 26 | do { \ |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 27 | } while (0) |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame] | 28 | #define wpi_setErrorWithContextRange(code, min, max, req, context) \ |
| 29 | do { \ |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 30 | } while (0) |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame] | 31 | |
| 32 | #define wpi_setHALError(code) \ |
| 33 | do { \ |
| 34 | } while (0) |
| 35 | |
| 36 | #define wpi_setHALErrorWithRange(code, min, max, req) \ |
| 37 | do { \ |
| 38 | } while (0) |
| 39 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 40 | #define wpi_setError(code) wpi_setErrorWithContext(code, "") |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame] | 41 | #define wpi_setStaticErrorWithContext(object, code, context) \ |
| 42 | do { \ |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 43 | } while (0) |
| 44 | #define wpi_setStaticError(object, code) \ |
| 45 | wpi_setStaticErrorWithContext(object, code, "") |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame] | 46 | |
| 47 | #define wpi_setGlobalErrorWithContext(code, context) \ |
| 48 | do { \ |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 49 | } while (0) |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame] | 50 | |
| 51 | #define wpi_setGlobalHALError(code) \ |
| 52 | do { \ |
| 53 | } while (0) |
| 54 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 55 | #define wpi_setGlobalError(code) wpi_setGlobalErrorWithContext(code, "") |
| 56 | #define wpi_setWPIErrorWithContext(error, context) \ |
| 57 | do { \ |
| 58 | } while (0) |
| 59 | #define wpi_setWPIError(error) wpi_setWPIErrorWithContext(error, "") |
| 60 | #define wpi_setStaticWPIErrorWithContext(object, error, context) \ |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame] | 61 | object->SetWPIError(wpi_error_s_##error(), (context), __FILE__, \ |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 62 | __FUNCTION__, __LINE__) |
| 63 | #define wpi_setStaticWPIError(object, error) \ |
| 64 | wpi_setStaticWPIErrorWithContext(object, error, "") |
| 65 | #define wpi_setGlobalWPIErrorWithContext(error, context) \ |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame] | 66 | ::frc::ErrorBase::SetGlobalWPIError(wpi_error_s_##error(), (context), \ |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 67 | __FILE__, __FUNCTION__, __LINE__) |
| 68 | #define wpi_setGlobalWPIError(error) wpi_setGlobalWPIErrorWithContext(error, "") |
| 69 | |
| 70 | namespace frc { |
| 71 | |
| 72 | inline bool StatusIsFatal() { return false; } |
| 73 | |
| 74 | } // namespace frc |