blob: c92ca52fc6be5d2d1082c8d2dcf8c85813e2c4bc [file] [log] [blame]
Parker Schuhd3b7a8872018-02-19 16:42:27 -08001/*----------------------------------------------------------------------------*/
James Kuszmaul41fa78a2019-12-14 20:53:14 -08002/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
Parker Schuhd3b7a8872018-02-19 16:42:27 -08003/* 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 Kuszmaul41fa78a2019-12-14 20:53:14 -080010#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.
17extern "C" const char* HAL_GetErrorMessage(int32_t code);
Parker Schuhd3b7a8872018-02-19 16:42:27 -080018
19#define wpi_setErrnoErrorWithContext(context) \
20 this->SetErrnoError((context), __FILE__, __FUNCTION__, __LINE__)
21#define wpi_setErrnoError() wpi_setErrnoErrorWithContext("")
James Kuszmaul41fa78a2019-12-14 20:53:14 -080022#define wpi_setImaqErrorWithContext(code, context) \
23 do { \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080024 } while (0)
James Kuszmaul41fa78a2019-12-14 20:53:14 -080025#define wpi_setErrorWithContext(code, context) \
26 do { \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080027 } while (0)
James Kuszmaul41fa78a2019-12-14 20:53:14 -080028#define wpi_setErrorWithContextRange(code, min, max, req, context) \
29 do { \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080030 } while (0)
James Kuszmaul41fa78a2019-12-14 20:53:14 -080031
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 Schuhd3b7a8872018-02-19 16:42:27 -080040#define wpi_setError(code) wpi_setErrorWithContext(code, "")
James Kuszmaul41fa78a2019-12-14 20:53:14 -080041#define wpi_setStaticErrorWithContext(object, code, context) \
42 do { \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080043 } while (0)
44#define wpi_setStaticError(object, code) \
45 wpi_setStaticErrorWithContext(object, code, "")
James Kuszmaul41fa78a2019-12-14 20:53:14 -080046
47#define wpi_setGlobalErrorWithContext(code, context) \
48 do { \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080049 } while (0)
James Kuszmaul41fa78a2019-12-14 20:53:14 -080050
51#define wpi_setGlobalHALError(code) \
52 do { \
53 } while (0)
54
Parker Schuhd3b7a8872018-02-19 16:42:27 -080055#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 Kuszmaul41fa78a2019-12-14 20:53:14 -080061 object->SetWPIError(wpi_error_s_##error(), (context), __FILE__, \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080062 __FUNCTION__, __LINE__)
63#define wpi_setStaticWPIError(object, error) \
64 wpi_setStaticWPIErrorWithContext(object, error, "")
65#define wpi_setGlobalWPIErrorWithContext(error, context) \
James Kuszmaul41fa78a2019-12-14 20:53:14 -080066 ::frc::ErrorBase::SetGlobalWPIError(wpi_error_s_##error(), (context), \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080067 __FILE__, __FUNCTION__, __LINE__)
68#define wpi_setGlobalWPIError(error) wpi_setGlobalWPIErrorWithContext(error, "")
69
70namespace frc {
71
72inline bool StatusIsFatal() { return false; }
73
74} // namespace frc