1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#ifndef MESSAGE_ERROR_HPP__
#define MESSAGE_ERROR_HPP__
#include <system_error>
namespace MessageError {
enum class Code { json_parsing_error = -1001, json_not_an_object = -1002 };
std::error_category const &category() noexcept;
} // namespace MessageError
namespace std {
template <> struct is_error_code_enum<MessageError::Code> : public true_type {};
template <>
struct is_error_condition_enum<MessageError::Code> : public true_type {};
} // namespace std
namespace MessageError {
inline std::error_code make_error_code(Code const e) noexcept {
return {static_cast<int>(e), category()};
}
inline std::error_condition make_error_condition(Code const e) noexcept {
return {static_cast<int>(e), category()};
}
} // namespace MessageError
#endif
|