unilink
0.4.3
A simple C++ library for unified async communication
error_codes.hpp
Go to the documentation of this file.
1
/*
2
* Copyright 2025 Jinwoo Sung
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
19
#include <string>
20
21
namespace
unilink
{
22
26
enum class
ErrorCode
{
27
Success
= 0,
28
Unknown
,
29
InvalidConfiguration
,
30
InternalError
,
31
IoError
,
32
33
// Connection related
34
ConnectionRefused
,
35
ConnectionReset
,
36
ConnectionAborted
,
37
TimedOut
,
38
NotConnected
,
39
AlreadyConnected
,
40
41
// Server related
42
PortInUse
,
43
AccessDenied
,
44
45
// Lifecycle
46
Stopped
,
47
StartFailed
48
};
49
53
inline
std::string
to_string
(
ErrorCode
code) {
54
switch
(code) {
55
case
ErrorCode::Success
:
56
return
"Success"
;
57
case
ErrorCode::Unknown
:
58
return
"Unknown Error"
;
59
case
ErrorCode::InvalidConfiguration
:
60
return
"Invalid Configuration"
;
61
case
ErrorCode::InternalError
:
62
return
"Internal Error"
;
63
case
ErrorCode::IoError
:
64
return
"I/O Error"
;
65
case
ErrorCode::ConnectionRefused
:
66
return
"Connection Refused"
;
67
case
ErrorCode::ConnectionReset
:
68
return
"Connection Reset"
;
69
case
ErrorCode::ConnectionAborted
:
70
return
"Connection Aborted"
;
71
case
ErrorCode::TimedOut
:
72
return
"Operation Timed Out"
;
73
case
ErrorCode::NotConnected
:
74
return
"Not Connected"
;
75
case
ErrorCode::AlreadyConnected
:
76
return
"Already Connected"
;
77
case
ErrorCode::PortInUse
:
78
return
"Port Already In Use"
;
79
case
ErrorCode::AccessDenied
:
80
return
"Access Denied"
;
81
case
ErrorCode::Stopped
:
82
return
"Stopped"
;
83
case
ErrorCode::StartFailed
:
84
return
"Failed to Start"
;
85
default
:
86
return
"Unknown Error Code"
;
87
}
88
}
89
90
}
// namespace unilink
unilink
Definition:
common.hpp:37
unilink::ErrorCode
ErrorCode
Structured error codes for Unilink.
Definition:
error_codes.hpp:26
unilink::ErrorCode::AlreadyConnected
@ AlreadyConnected
unilink::ErrorCode::NotConnected
@ NotConnected
unilink::ErrorCode::Success
@ Success
unilink::ErrorCode::StartFailed
@ StartFailed
unilink::ErrorCode::InternalError
@ InternalError
unilink::ErrorCode::Unknown
@ Unknown
unilink::ErrorCode::TimedOut
@ TimedOut
unilink::ErrorCode::ConnectionRefused
@ ConnectionRefused
unilink::ErrorCode::ConnectionReset
@ ConnectionReset
unilink::ErrorCode::Stopped
@ Stopped
unilink::ErrorCode::AccessDenied
@ AccessDenied
unilink::ErrorCode::PortInUse
@ PortInUse
unilink::ErrorCode::ConnectionAborted
@ ConnectionAborted
unilink::ErrorCode::IoError
@ IoError
unilink::ErrorCode::InvalidConfiguration
@ InvalidConfiguration
unilink::to_string
std::string to_string(ErrorCode code)
Convert ErrorCode to human-readable string.
Definition:
error_codes.hpp:53
unilink
base
error_codes.hpp
Generated on Wed Mar 25 2026 21:38:57 for unilink by
1.9.1