rotor
Event loop friendly C++ actor micro-framework
 
Loading...
Searching...
No Matches
error_code.h
1#pragma once
2
3//
4// Copyright (c) 2019-2021 Ivan Baidakou (basiliscos) (the dot dmol at gmail dot com)
5//
6// Distributed under the MIT Software License
7//
8
9#include <string>
10#include <system_error>
11#include "rotor/export.h"
12
13#if defined(_MSC_VER)
14#pragma warning(push)
15#pragma warning(disable : 4251)
16#pragma warning(disable : 4275)
17#endif
18
19namespace rotor {
20
22enum class error_code_t {
23 success = 0,
24 cancelled,
25 request_timeout,
26 supervisor_defined,
27 already_registered,
28 actor_misconfigured,
29 actor_not_linkable,
30 already_linked,
31 failure_escalation,
32 registration_failed,
33 discovery_failed,
34 unknown_service,
35};
36
38enum class shutdown_code_t {
39 normal = 0,
40 supervisor_shutdown,
41 child_down,
42 child_init_failed,
43 init_failed,
44 unlink_requested,
45};
46
47namespace details {
48
50class ROTOR_API error_code_category : public std::error_category {
51 public:
53 virtual const char *name() const noexcept override;
54
56 virtual std::string message(int c) const override;
57};
58
60class ROTOR_API shutdown_code_category : public std::error_category {
61 public:
63 virtual const char *name() const noexcept override;
64
66 virtual std::string message(int c) const override;
67};
68
69} // namespace details
70
72ROTOR_API const details::error_code_category &error_code_category();
73
75ROTOR_API const details::shutdown_code_category &shutdown_code_category();
76
78ROTOR_API inline std::error_code make_error_code(const error_code_t e) {
79 return {static_cast<int>(e), error_code_category()};
80}
81
83ROTOR_API inline std::error_code make_error_code(const shutdown_code_t e) {
84 return {static_cast<int>(e), shutdown_code_category()};
85}
86
87} // namespace rotor
88
89namespace std {
90template <> struct is_error_code_enum<rotor::error_code_t> : std::true_type {};
91template <> struct is_error_code_enum<rotor::shutdown_code_t> : std::true_type {};
92} // namespace std
93
94#if defined(_MSC_VER)
95#pragma warning(pop)
96#endif
category support for rotor error codes
Definition error_code.h:50
virtual const char * name() const noexcept override
category support for rotor shutdown codes
Definition error_code.h:60
virtual const char * name() const noexcept override
Basic namespace for all rotor functionalities.
Definition rotor.hpp:21
shutdown_code_t
actor shutdown reasons as error code
Definition error_code.h:38
ROTOR_API std::error_code make_error_code(const error_code_t e)
makes std::error_code from rotor error code enumerations
Definition error_code.h:78
ROTOR_API const details::error_code_category & error_code_category()
returns error code category for rotor error codes
ROTOR_API const details::shutdown_code_category & shutdown_code_category()
returns error code category for rotor shutdown codes
error_code_t
fatal error codes in rotor
Definition error_code.h:22