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
103 virtual std::error_condition default_error_condition (int code) const noexcept override;
104
111 virtual bool equivalent (const std::error_code& code, int condition) const noexcept override;
112
119 virtual bool equivalent (int code, const std::error_condition& condition) const noexcept override;
120 };
121
126 const std::error_category& getErrorCategory () noexcept;
127
133 std::error_code make_error_code (join::Errc code) noexcept;
134
140 std::error_condition make_error_condition (join::Errc code) noexcept;
141}
142
143namespace std
144{
145 template <>
146 struct is_error_condition_enum<join::Errc> : public true_type
147 {
148 };
149}
150
151#endif
Error category.
Definition error.hpp:60
virtual std::error_condition default_error_condition(int code) const noexcept override
translate an Errc to the system error condition representing it.
Definition error.cpp:86
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
check if the given error code is equivalent to an Errc.
Definition error.cpp:125
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:185
std::error_code make_error_code(join::Errc code) noexcept
Create an std::error_code object.
Definition error.cpp:195
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:204
Definition error.hpp:144