ORE Studio 0.0.4
Loading...
Searching...
No Matches
error_code.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_UTILITY_SERIALIZATION_ERROR_CODE_HPP
21#define ORES_UTILITY_SERIALIZATION_ERROR_CODE_HPP
22
23#include <string>
24#include <ostream>
25#include <cstdint>
26#include <magic_enum/magic_enum.hpp>
27
28namespace ores::utility::serialization {
29
36enum class error_code : std::uint16_t {
37 none = 0x0000,
38 version_mismatch = 0x0001,
39 crc_validation_failed = 0x0002,
40 invalid_message_type = 0x0003,
41 handshake_timeout = 0x0004,
42 handshake_failed = 0x0005,
43 payload_too_large = 0x0006,
44 network_error = 0x0007,
45 handler_error = 0x0008,
46 database_error = 0x0009,
47 authentication_failed = 0x000A,
48 authorization_failed = 0x000B,
49 invalid_request = 0x000C,
50 bootstrap_mode_only = 0x000D,
51 bootstrap_mode_forbidden = 0x000E,
52 weak_password = 0x000F,
53 not_localhost = 0x0010,
54 database_unavailable = 0x0011,
55 decompression_failed = 0x0012,
56 unsupported_compression = 0x0013,
57 compression_failed = 0x0014,
58 signup_disabled = 0x0015,
59 username_taken = 0x0016,
60 email_taken = 0x0017,
61 signup_requires_authorization = 0x0018,
62 payload_incomplete = 0x0019,
63 limit_exceeded = 0x001A,
64 last_value
65};
66
73inline std::ostream& operator<<(std::ostream& os, error_code ec) {
74 return os << magic_enum::enum_name(ec)
75 << " (0x" << std::hex << static_cast<std::uint16_t>(ec) << std::dec << ")";
76}
77
81inline std::string to_string(error_code ec) {
82 return std::string(magic_enum::enum_name(ec));
83}
84
85}
86
87#endif
error_code
Error codes returned by service-layer request helpers.
Definition error_code.hpp:28