WPILibC++  2019.1.1-beta-4-17-g300eeb3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Error.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2018 FIRST. All Rights Reserved. */
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 #ifndef WPIUTIL_WPI_UV_ERROR_H_
9 #define WPIUTIL_WPI_UV_ERROR_H_
10 
11 #include <uv.h>
12 
13 namespace wpi {
14 namespace uv {
15 
19 class Error {
20  public:
21  Error() : m_err(UV_UNKNOWN) {}
22  explicit Error(int err) : m_err(err) {}
23 
27  explicit operator bool() const { return m_err < 0; }
28 
32  int code() const { return m_err; }
33 
37  const char* str() const { return uv_strerror(m_err); }
38 
42  const char* name() const { return uv_err_name(m_err); }
43 
44  private:
45  int m_err;
46 };
47 
48 } // namespace uv
49 } // namespace wpi
50 
51 #endif // WPIUTIL_WPI_UV_ERROR_H_
const char * str() const
Returns the error message.
Definition: Error.h:37
int code() const
Returns the error code.
Definition: Error.h:32
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
Error code.
Definition: Error.h:19
const char * name() const
Returns the error name.
Definition: Error.h:42