blob: f0dfe3e44fde027f8e4799219d566893d66656ce [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
James Kuszmaul41fa78a2019-12-14 20:53:14 -080012#include <wpi/mutex.h>
13
14// Forward declared manually to avoid needing to pull in entire HAL header.
15extern "C" const char* HAL_GetErrorMessage(int32_t code);
Parker Schuhd3b7a8872018-02-19 16:42:27 -080016
17#define wpi_setErrnoErrorWithContext(context) \
18 this->SetErrnoError((context), __FILE__, __FUNCTION__, __LINE__)
19#define wpi_setErrnoError() wpi_setErrnoErrorWithContext("")
James Kuszmaul41fa78a2019-12-14 20:53:14 -080020#define wpi_setImaqErrorWithContext(code, context) \
21 do { \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080022 } while (0)
James Kuszmaul41fa78a2019-12-14 20:53:14 -080023#define wpi_setErrorWithContext(code, context) \
24 do { \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080025 } while (0)
James Kuszmaul41fa78a2019-12-14 20:53:14 -080026#define wpi_setErrorWithContextRange(code, min, max, req, context) \
27 do { \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080028 } while (0)
James Kuszmaul41fa78a2019-12-14 20:53:14 -080029
30#define wpi_setHALError(code) \
31 do { \
32 } while (0)
33
34#define wpi_setHALErrorWithRange(code, min, max, req) \
35 do { \
36 } while (0)
37
Parker Schuhd3b7a8872018-02-19 16:42:27 -080038#define wpi_setError(code) wpi_setErrorWithContext(code, "")
James Kuszmaul41fa78a2019-12-14 20:53:14 -080039#define wpi_setStaticErrorWithContext(object, code, context) \
40 do { \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080041 } while (0)
42#define wpi_setStaticError(object, code) \
43 wpi_setStaticErrorWithContext(object, code, "")
James Kuszmaul41fa78a2019-12-14 20:53:14 -080044
45#define wpi_setGlobalErrorWithContext(code, context) \
46 do { \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080047 } while (0)
James Kuszmaul41fa78a2019-12-14 20:53:14 -080048
49#define wpi_setGlobalHALError(code) \
50 do { \
51 } while (0)
52
Parker Schuhd3b7a8872018-02-19 16:42:27 -080053#define wpi_setGlobalError(code) wpi_setGlobalErrorWithContext(code, "")
54#define wpi_setWPIErrorWithContext(error, context) \
55 do { \
56 } while (0)
57#define wpi_setWPIError(error) wpi_setWPIErrorWithContext(error, "")
58#define wpi_setStaticWPIErrorWithContext(object, error, context) \
James Kuszmaul41fa78a2019-12-14 20:53:14 -080059 object->SetWPIError(wpi_error_s_##error(), (context), __FILE__, \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080060 __FUNCTION__, __LINE__)
61#define wpi_setStaticWPIError(object, error) \
62 wpi_setStaticWPIErrorWithContext(object, error, "")
63#define wpi_setGlobalWPIErrorWithContext(error, context) \
James Kuszmaul41fa78a2019-12-14 20:53:14 -080064 ::frc::ErrorBase::SetGlobalWPIError(wpi_error_s_##error(), (context), \
Parker Schuhd3b7a8872018-02-19 16:42:27 -080065 __FILE__, __FUNCTION__, __LINE__)
66#define wpi_setGlobalWPIError(error) wpi_setGlobalWPIErrorWithContext(error, "")
67
68namespace frc {
69
70inline bool StatusIsFatal() { return false; }
71
72} // namespace frc