join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
error.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_CORE_ERROR_HPP
26#define JOIN_CORE_ERROR_HPP
27
28// C++.
29#include <system_error>
30
31namespace join
32{
34 extern thread_local std::error_code lastError;
35
55
59 class ErrorCategory : public std::error_category
60 {
61 public:
65 constexpr ErrorCategory () noexcept = default;
66
71 ErrorCategory (const ErrorCategory&) = delete;
72
78 ErrorCategory& operator= (const ErrorCategory&) = delete;
79
83 virtual ~ErrorCategory () = default;
84
89 virtual const char* name () const noexcept override;
90
96 virtual std::string message (int code) const noexcept override;
97
104 virtual bool equivalent (const std::error_code& code, int condition) const noexcept override;
105
112 virtual bool equivalent (int code, const std::error_condition& condition) const noexcept override;
113 };
114
119 const std::error_category& getErrorCategory () noexcept;
120
126 std::error_code make_error_code (join::Errc code) noexcept;
127
133 std::error_condition make_error_condition (join::Errc code) noexcept;
134}
135
136namespace std
137{
138 template <>
139 struct is_error_condition_enum<join::Errc> : public true_type
140 {
141 };
142}
143
144#endif
Error category.
Definition error.hpp:60
virtual std::string message(int code) const noexcept override
Translate error code to human readable error string.
Definition error.cpp:47
constexpr ErrorCategory() noexcept=default
Create instance.
virtual bool equivalent(const std::error_code &code, int condition) const noexcept override
find equivalent from Errc to system error code.
Definition error.cpp:86
virtual const char * name() const noexcept override
Get error category name.
Definition error.cpp:38
Definition acceptor.hpp:32
Errc
Generic error codes.
Definition error.hpp:40
const std::error_category & getErrorCategory() noexcept
Get error category.
Definition error.cpp:140
std::error_code make_error_code(join::Errc code) noexcept
Create an std::error_code object.
Definition error.cpp:150
thread_local std::error_code lastError
last error.
Definition error.cpp:32
std::error_condition make_error_condition(join::Errc code) noexcept
Create an std::error_condition object.
Definition error.cpp:159
Definition error.hpp:137