File: MessageError.h

package info (click to toggle)
js8call 2.5.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,720 kB
  • sloc: cpp: 562,655; sh: 898; python: 132; ansic: 102; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 761 bytes parent folder | download
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