WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
Error.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <uv.h>
8
9namespace wpi::net::uv {
10
11/**
12 * Error code.
13 */
14class Error {
15 public:
16 Error() = default;
17 explicit Error(int err) : m_err(err) {}
18
19 /**
20 * Boolean conversion. Returns true if error, false if ok.
21 */
22 explicit operator bool() const { return m_err < 0; }
23
24 /**
25 * Returns the error code.
26 */
27 int code() const { return m_err; }
28
29 /**
30 * Returns the error message.
31 */
32 const char* str() const { return uv_strerror(m_err); }
33
34 /**
35 * Returns the error name.
36 */
37 const char* name() const { return uv_err_name(m_err); }
38
39 private:
40 int m_err{0};
41};
42
43} // namespace wpi::net::uv
int code() const
Returns the error code.
Definition Error.hpp:27
const char * str() const
Returns the error message.
Definition Error.hpp:32
const char * name() const
Returns the error name.
Definition Error.hpp:37
Error(int err)
Definition Error.hpp:17
Definition Errors.hpp:112
Definition Prepare.hpp:14
UV_EXTERN const char * uv_strerror(int err)
UV_EXTERN const char * uv_err_name(int err)