IRC_SERVER
By @hyunjunk (hyunjun2372@gmail.com)
Loading...
Searching...
No Matches
IrcErrorCode.hpp
Go to the documentation of this file.
1#pragma once
2
4
5/** Tuple of error code, error number, and error message. */
6#define IRC_ERROR_CODE_TUPLE_LIST \
7 IRC_ERROR_CODE_X(IRC_SUCCESS , 0, "Success") \
8 IRC_ERROR_CODE_X(IRC_FAILED_UNREACHABLE_CODE, 5, "Failed to reach the unreachable code") \
9 IRC_ERROR_CODE_X(IRC_SHUTDOWN , 6, "Shutdown") \
10 \
11 /** @name Related CreateServer() */ \
12 /**@{*/ \
13 IRC_ERROR_CODE_X(IRC_INVALID_PORT , 100, "Invalid port number") \
14 IRC_ERROR_CODE_X(IRC_PASSWORD_TOO_SHORT, 101, "Password is too short") \
15 IRC_ERROR_CODE_X(IRC_PASSWORD_TOO_LONG , 102, "Password is too long") \
16 IRC_ERROR_CODE_X(IRC_INVALID_PASSWORD , 103, "Invalid password") \
17 /**@}*/ \
18 \
19 /** @name Related SocketAPI */ \
20 /**@{*/ \
21 IRC_ERROR_CODE_X(IRC_FAILED_TO_CREATE_SOCKET , 200, "Failed to create socket") \
22 IRC_ERROR_CODE_X(IRC_FAILED_TO_BIND_SOCKET , 201, "Failed to bind socket") \
23 IRC_ERROR_CODE_X(IRC_FAILED_TO_LISTEN_SOCKET , 202, "Failed to listen on socket") \
24 IRC_ERROR_CODE_X(IRC_FAILED_TO_ACCEPT_SOCKET , 203, "Failed to accept on socket") \
25 IRC_ERROR_CODE_X(IRC_FAILED_TO_CONNECT_SOCKET , 204, "Failed to connect on socket") \
26 IRC_ERROR_CODE_X(IRC_FAILED_TO_SEND_SOCKET , 205, "Failed to send on socket") \
27 IRC_ERROR_CODE_X(IRC_FAILED_TO_RECV_SOCKET , 206, "Failed to recv on socket") \
28 IRC_ERROR_CODE_X(IRC_FAILED_TO_CLOSE_SOCKET , 207, "Failed to close on socket") \
29 IRC_ERROR_CODE_X(IRC_FAILED_TO_SHUTDOWN_SOCKET , 208, "Failed to shutdown on socket") \
30 IRC_ERROR_CODE_X(IRC_FAILED_TO_SETSOCKOPT_SOCKET, 209, "Failed to setsockopt on socket") \
31 IRC_ERROR_CODE_X(IRC_ERROR_LISTEN_SOCKET , 210, "Listen socket error in eventLoop") \
32 /**@}*/ \
33 \
34 /** @name Related kqueue and kevent */ \
35 /**@{*/ \
36 IRC_ERROR_CODE_X(IRC_FAILED_TO_CREATE_KQUEUE , 300, "Failed to create kqueue") \
37 IRC_ERROR_CODE_X(IRC_FAILED_TO_ADD_KEVENT , 301, "Failed to add kqueue") \
38 IRC_ERROR_CODE_X(IRC_FAILED_TO_DEL_KEVENT , 302, "Failed to del kqueue") \
39 IRC_ERROR_CODE_X(IRC_FAILED_TO_WAIT_KEVENT , 303, "Failed to wait kevent") \
40 IRC_ERROR_CODE_X(IRC_FAILED_TO_OBSERVE_KEVENT , 304, "Failed to observe kevent") \
41 IRC_ERROR_CODE_X(IRC_ERROR_LISTEN_SOCKET_EVENT, 305, "Listen socket event error") \
42 IRC_ERROR_CODE_X(IRC_ERROR_CLIENT_SOCKET_EVENT, 306, "Client socket event error") \
43 /**@}*/
44
45namespace IRC
46{
47 /** Error Codes Enum */
48 typedef enum
49 {
50#define IRC_ERROR_CODE_X(code, number, message) code = number,
53#undef IRC_ERROR_CODE_X
55
56 /** Get the error message from the error code.
57 *
58 * @param errorCode Error code.
59 * @return const char* Error message.
60 */
61 inline const char *GetIrcErrorMessage(const EIrcErrorCode errorCode)
62 {
63 switch (errorCode)
64 {
65#define IRC_ERROR_CODE_X(code, number, message) \
66 case code: \
67 return message;
69#undef IRC_ERROR_CODE_X
70 default:
71 return "Unknown error";
72 }
73 }
74}
#define IRC_ERROR_CODE_TUPLE_LIST
Tuple of error code, error number, and error message.
Definition IrcErrorCode.hpp:6
Definition ChannelControlBlock.hpp:12
const char * GetIrcErrorMessage(const EIrcErrorCode errorCode)
Get the error message from the error code.
Definition IrcErrorCode.hpp:61
EIrcErrorCode
Error Codes Enum.
Definition IrcErrorCode.hpp:49
@ IRC_ERROR_CODE_MAX
Definition IrcErrorCode.hpp:52