1 // This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
2 // the main distribution directory for license terms and copyright or visit
3 // https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
4 
5 // This file is partially included in the manual, do not modify
6 // without updating the references in the *.tex files!
7 // Manual references: lines 32-117 (Error.tex)
8 
9 #pragma once
10 
11 #include <cstdint>
12 #include <string>
13 #include <type_traits>
14 
15 #include "caf/default_enum_inspect.hpp"
16 #include "caf/detail/core_export.hpp"
17 #include "caf/fwd.hpp"
18 #include "caf/is_error_code_enum.hpp"
19 
20 namespace caf {
21 
22 // --(rst-sec-begin)--
23 /// SEC stands for "System Error Code". This enum contains error codes for
24 /// ::actor_system and its modules.
25 enum class sec : uint8_t {
26   /// No error.
27   none = 0,
28   /// Indicates that an actor dropped an unexpected message.
29   unexpected_message = 1,
30   /// Indicates that a response message did not match the provided handler.
31   unexpected_response,
32   /// Indicates that the receiver of a request is no longer alive.
33   request_receiver_down,
34   /// Indicates that a request message timed out.
35   request_timeout,
36   /// Indicates that requested group module does not exist.
37   no_such_group_module = 5,
38   /// Unpublishing or connecting failed: no actor bound to given port.
39   no_actor_published_at_port,
40   /// Connecting failed because a remote actor had an unexpected interface.
41   unexpected_actor_messaging_interface,
42   /// Migration failed because the state of an actor is not serializable.
43   state_not_serializable,
44   /// An actor received an unsupported key for `('sys', 'get', key)` messages.
45   unsupported_sys_key,
46   /// An actor received an unsupported system message.
47   unsupported_sys_message = 10,
48   /// A remote node disconnected during CAF handshake.
49   disconnect_during_handshake,
50   /// Tried to forward a message via BASP to an invalid actor handle.
51   cannot_forward_to_invalid_actor,
52   /// Tried to forward a message via BASP to an unknown node ID.
53   no_route_to_receiving_node,
54   /// Middleman could not assign a connection handle to a broker.
55   failed_to_assign_scribe_from_handle,
56   /// Middleman could not assign an acceptor handle to a broker.
57   failed_to_assign_doorman_from_handle = 15,
58   /// User requested to close port 0 or to close a port not managed by CAF.
59   cannot_close_invalid_port,
60   /// Middleman could not connect to a remote node.
61   cannot_connect_to_node,
62   /// Middleman could not open requested port.
63   cannot_open_port,
64   /// A C system call in the middleman failed.
65   network_syscall_failed,
66   /// A function received one or more invalid arguments.
67   invalid_argument = 20,
68   /// A network socket reported an invalid network protocol family.
69   invalid_protocol_family,
70   /// Middleman could not publish an actor because it was invalid.
71   cannot_publish_invalid_actor,
72   /// A remote spawn failed because the provided types did not match.
73   cannot_spawn_actor_from_arguments,
74   /// Serialization failed because there was not enough data to read.
75   end_of_stream,
76   /// Serialization failed because no CAF context is available.
77   no_context = 25,
78   /// Serialization failed because CAF misses run-time type information.
79   unknown_type,
80   /// Serialization of actors failed because no proxy registry is available.
81   no_proxy_registry,
82   /// An exception was thrown during message handling.
83   runtime_error,
84   /// Linking to a remote actor failed because actor no longer exists.
85   remote_linking_failed,
86   /// Adding an upstream to a stream failed.
87   cannot_add_upstream = 30,
88   /// Adding an upstream to a stream failed because it already exists.
89   upstream_already_exists,
90   /// Unable to process upstream messages because upstream is invalid.
91   invalid_upstream,
92   /// Adding a downstream to a stream failed.
93   cannot_add_downstream,
94   /// Adding a downstream to a stream failed because it already exists.
95   downstream_already_exists,
96   /// Unable to process downstream messages because downstream is invalid.
97   invalid_downstream = 35,
98   /// Cannot start streaming without next stage.
99   no_downstream_stages_defined,
100   /// Actor failed to initialize state after receiving a stream handshake.
101   stream_init_failed,
102   /// Unable to process a stream since due to missing state.
103   invalid_stream_state,
104   /// Stream aborted due to unexpected error.
105   unhandled_stream_error,
106   /// A function view was called without assigning an actor first.
107   bad_function_call = 40,
108   /// Feature is disabled in the actor system config.
109   feature_disabled,
110   /// Failed to open file.
111   cannot_open_file,
112   /// A socket descriptor argument is invalid.
113   socket_invalid,
114   /// A socket became disconnected from the remote host (hang up).
115   socket_disconnected,
116   /// An operation on a socket (e.g. `poll`) failed.
117   socket_operation_failed = 45,
118   /// A resource is temporarily unavailable or would block.
119   unavailable_or_would_block,
120   /// Connection refused because of incompatible CAF versions.
121   incompatible_versions,
122   /// Connection refused because of incompatible application IDs.
123   incompatible_application_ids,
124   /// The middleman received a malformed BASP message from another node.
125   malformed_basp_message,
126   /// The middleman closed a connection because it failed to serialize or
127   /// deserialize a payload.
128   serializing_basp_payload_failed = 50,
129   /// The middleman closed a connection to itself or an already connected node.
130   redundant_connection,
131   /// Resolving a path on a remote node failed.
132   remote_lookup_failed,
133   /// Serialization failed because actor_system::tracing_context is null.
134   no_tracing_context,
135   /// No request produced a valid result.
136   all_requests_failed,
137   /// Deserialization failed because an invariant got violated after reading
138   /// the content of a field.
139   field_invariant_check_failed = 55,
140   /// Deserialization failed because a setter rejected the input.
141   field_value_synchronization_failed,
142   /// Deserialization failed because the source announced an invalid type.
143   invalid_field_type,
144   /// Serialization failed because a type was flagged as unsafe message type.
145   unsafe_type,
146   /// Serialization failed because a save callback returned `false`.
147   save_callback_failed,
148   /// Deserialization failed because a load callback returned `false`.
149   load_callback_failed = 60,
150   /// Converting between two types failed.
151   conversion_failed,
152   /// A network connection was closed by the remote side.
153   connection_closed,
154   /// An operation failed because run-time type information diverged from the
155   /// expected type.
156   type_clash,
157   /// An operation failed because the callee does not implement this
158   /// functionality.
159   unsupported_operation,
160   /// A key lookup failed.
161   no_such_key = 65,
162   /// An destroyed a response promise without calling deliver or delegate on it.
163   broken_promise,
164   /// Disconnected from a BASP node after reaching the connection timeout.
165   connection_timeout,
166 };
167 // --(rst-sec-end)--
168 
169 /// @relates sec
170 CAF_CORE_EXPORT std::string to_string(sec);
171 
172 /// @relates sec
173 CAF_CORE_EXPORT bool from_string(string_view, sec&);
174 
175 /// @relates sec
176 CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<sec>, sec&);
177 
178 /// @relates sec
179 template <class Inspector>
inspect(Inspector & f,sec & x)180 bool inspect(Inspector& f, sec& x) {
181   return default_enum_inspect(f, x);
182 }
183 
184 } // namespace caf
185 
186 CAF_ERROR_CODE_ENUM(sec)
187