ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
systemerrors.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header file is part of sub-namespace #alib::lang::system of module \alib_basecamp of
4/// the \aliblong.
5///
6/// \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
7/// Published under \ref mainpage_license "Boost Software License".
8//==================================================================================================
9#ifndef HPP_ALIB_LANG_SYSTEM_ERRORS
10#define HPP_ALIB_LANG_SYSTEM_ERRORS 1
11#pragma once
13
15
16#if defined( __GNUC__ ) || ( defined(_WIN32) && defined(_MSC_VER))
17# include <errno.h>
18#endif
19
20namespace alib { namespace lang::system {
21
22//==================================================================================================
23/// Denotes result values returned by system functions (glibc, etc).
24//==================================================================================================
25enum class SystemErrors
26{
27 UNKNOWN = -1 , ///< Unknown Error
28 OK = 0 , ///< No Error
29 None = 0 , ///< No Error (alias for OK)
30
31 #if defined (__GLIBC__) || defined(__APPLE__) || defined(__ANDROID_NDK__)
32
33 eperm = EPERM , ///< 1 "Operation not permitted"
34 enoent = ENOENT , ///< 2 "No such file or directory"
35 esrch = ESRCH , ///< 3 "No such process"
36 eintr = EINTR , ///< 4 "Interrupted system call"
37 eio = EIO , ///< 5 "I/O error"
38 enxio = ENXIO , ///< 6 "No such device or address"
39 e2Big = E2BIG , ///< 7 "Argument list too long"
40 enoexec = ENOEXEC , ///< 8 "Exec format error"
41 ebadf = EBADF , ///< 9 "Bad file number"
42 echild = ECHILD , ///< 10 "No child processes"
43 eagain = EAGAIN , ///< 11 "Try again. (E.g operation would block)"
44 enomem = ENOMEM , ///< 12 "Out of memory"
45 eacces = EACCES , ///< 13 "Permission denied"
46 efault = EFAULT , ///< 14 "Bad address"
47 enotblk = ENOTBLK , ///< 15 "Block device required"
48 ebusy = EBUSY , ///< 16 "Device or resource busy"
49 eexist = EEXIST , ///< 17 "File exists"
50 exdev = EXDEV , ///< 18 "Cross-device link"
51 enodev = ENODEV , ///< 19 "No such device"
52 enotdir = ENOTDIR , ///< 20 "Not a directory"
53 eisdir = EISDIR , ///< 21 "Is a directory"
54 einval = EINVAL , ///< 22 "Invalid argument"
55 enfile = ENFILE , ///< 23 "File table overflow"
56 emfile = EMFILE , ///< 24 "Too many open files"
57 enotty = ENOTTY , ///< 25 "Not a typewriter"
58 etxtbsy = ETXTBSY , ///< 26 "Text file busy"
59 efbig = EFBIG , ///< 27 "File too large"
60 enospc = ENOSPC , ///< 28 "No space left on device"
61 espipe = ESPIPE , ///< 29 "Illegal seek"
62 erofs = EROFS , ///< 30 "Read-only file system"
63 emlink = EMLINK , ///< 31 "Too many links"
64 epipe = EPIPE , ///< 32 "Broken pipe"
65 edom = EDOM , ///< 33 "Math argument out of domain of func"
66 erange = ERANGE , ///< 34 "Math result not representable"
67 edeadlk = EDEADLK , ///< 35 "Resource deadlock would occur"
68 enametoolong = ENAMETOOLONG , ///< 36 "File name too long"
69 enolck = ENOLCK , ///< 37 "No record locks available"
70 enosys = ENOSYS , ///< 38 "Invalid system call number"
71 enotempty = ENOTEMPTY , ///< 39 "Directory not empty"
72 eloop = ELOOP , ///< 40 "Too many symbolic links encountered"
73 enomsg = ENOMSG , ///< 42 "No message of desired type"
74 eidrm = EIDRM , ///< 43 "Identifier removed"
75#if !defined(__APPLE__)
76 echrng = ECHRNG , ///< 44 "Channel number out of range"
77 el2Nsync = EL2NSYNC , ///< 45 "Level 2 not synchronized"
78 el3Hlt = EL3HLT , ///< 46 "Level 3 halted"
79 el3Rst = EL3RST , ///< 47 "Level 3 reset"
80 elnrng = ELNRNG , ///< 48 "Link number out of range"
81 eunatch = EUNATCH , ///< 49 "Protocol driver not attached"
82
83 enocsi = ENOCSI , ///< 50 "No CSI structure available"
84 el2Hlt = EL2HLT , ///< 51 "Level 2 halted"
85 ebade = EBADE , ///< 52 "Invalid exchange"
86 ebadr = EBADR , ///< 53 "Invalid request descriptor"
87 exfull = EXFULL , ///< 54 "Exchange full"
88 enoano = ENOANO , ///< 55 "No anode"
89 ebadrqc = EBADRQC , ///< 56 "Invalid request code"
90 ebadslt = EBADSLT , ///< 57 "Invalid slot"
91 ebfont = EBFONT , ///< 59 "Bad font file format"
92#endif
93 enostr = ENOSTR , ///< 60 "Device not a stream"
94 enodata = ENODATA , ///< 61 "No data available"
95 etime = ETIME , ///< 62 "Timer expired"
96 enosr = ENOSR , ///< 63 "Out of streams resources"
97#if !defined(__APPLE__)
98 enonet = ENONET , ///< 64 "Machine is not on the network"
99 enopkg = ENOPKG , ///< 65 "Package not installed"
100#endif
101 eremote = EREMOTE , ///< 66 "Object is remote"
102 enolink = ENOLINK , ///< 67 "Link has been severed"
103#if !defined(__APPLE__)
104 eadv = EADV , ///< 68 "Advertise error"
105 esrmnt = ESRMNT , ///< 69 "Srmount error"
106 ecomm = ECOMM , ///< 70 "Communication error on send"
107#endif
108 eproto = EPROTO , ///< 71 "Protocol error"
109 emultihop = EMULTIHOP , ///< 72 "Multihop attempted"
110#if !defined(__APPLE__)
111 edotdot = EDOTDOT , ///< 73 "RFS specific error"
112#endif
113 ebadmsg = EBADMSG , ///< 74 "Not a data message"
114 eoverflow = EOVERFLOW , ///< 75 "Value too large for defined data type"
115#if !defined(__APPLE__)
116 enotuniq = ENOTUNIQ , ///< 76 "Name not unique on network"
117 ebadfd = EBADFD , ///< 77 "File descriptor in bad state"
118 eremchg = EREMCHG , ///< 78 "Remote address changed"
119 elibacc = ELIBACC , ///< 79 "Cannot access a needed shared library"
120 elibbad = ELIBBAD , ///< 80 "Accessing a corrupted shared library"
121 elibscn = ELIBSCN , ///< 81 ".lib section in a.out corrupted"
122 elibmax = ELIBMAX , ///< 82 "Attempting to link in too many shared libraries"
123 elibexec = ELIBEXEC , ///< 83 "Cannot exec a shared library directly"
124#endif
125 eilseq = EILSEQ , ///< 84 "Illegal byte sequence"
126#if !defined(__APPLE__)
127 erestart = ERESTART , ///< 85 "Interrupted system call should be restarted"
128 estrpipe = ESTRPIPE , ///< 86 "Streams pipe error"
129#endif
130 eusers = EUSERS , ///< 87 "Too many users"
131 enotsock = ENOTSOCK , ///< 88 "Socket operation on non-socket"
132 edestaddrreq = EDESTADDRREQ , ///< 89 "Destination address required"
133 emsgsize = EMSGSIZE , ///< 90 "Message too long"
134 eprototype = EPROTOTYPE , ///< 91 "Protocol wrong type for socket"
135 enoprotoopt = ENOPROTOOPT , ///< 92 "Protocol not available"
136 eprotonosupport = EPROTONOSUPPORT , ///< 93 "Protocol not supported"
137 esocktnosupport = ESOCKTNOSUPPORT , ///< 94 "Socket type not supported"
138 eopnotsupp = EOPNOTSUPP , ///< 95 "Operation not supported on transport endpoint"
139 epfnosupport = EPFNOSUPPORT , ///< 96 "Protocol family not supported"
140 eafnosupport = EAFNOSUPPORT , ///< 97 "Address family not supported by protocol"
141 eaddrinuse = EADDRINUSE , ///< 98 "Address already in use"
142 eaddrnotavail = EADDRNOTAVAIL , ///< 99 "Cannot assign requested address"
143 enetdown = ENETDOWN , ///< 100 "Network is down"
144 enetunreach = ENETUNREACH , ///< 101 "Network is unreachable"
145 enetreset = ENETRESET , ///< 102 "Network dropped connection because of reset"
146 econnaborted = ECONNABORTED , ///< 103 "Software caused connection abort"
147 econnreset = ECONNRESET , ///< 104 "Connection reset by peer"
148 enobufs = ENOBUFS , ///< 105 "No buffer space available"
149 eisconn = EISCONN , ///< 106 "Transport endpoint is already connected"
150 enotconn = ENOTCONN , ///< 107 "Transport endpoint is not connected"
151 eshutdown = ESHUTDOWN , ///< 108 "Cannot send after transport endpoint shutdown"
152 etoomanyrefs = ETOOMANYREFS , ///< 109 "Too many references: cannot splice"
153 etimedout = ETIMEDOUT , ///< 110 "Connection timed out"
154 econnrefused = ECONNREFUSED , ///< 111 "Connection refused"
155 ehostdown = EHOSTDOWN , ///< 112 "Host is down"
156 ehostunreach = EHOSTUNREACH , ///< 113 "No route to host"
157 ealready = EALREADY , ///< 114 "Operation already in progress"
158 einprogress = EINPROGRESS , ///< 115 "Operation now in progress"
159 estale = ESTALE , ///< 116 "Stale file handle"
160#if !defined(__APPLE__)
161 euclean = EUCLEAN , ///< 117 "Structure needs cleaning"
162 enotnam = ENOTNAM , ///< 118 "Not a XENIX named type file"
163 enavail = ENAVAIL , ///< 119 "No XENIX semaphores available"
164 eisnam = EISNAM , ///< 120 "Is a named type file"
165 eremoteio = EREMOTEIO , ///< 121 "Remote I/O error"
166#endif
167 edquot = EDQUOT , ///< 122 "Quota exceeded"
168#if !defined(__APPLE__)
169 enomedium = ENOMEDIUM , ///< 123 "No medium found"
170 emediumtype = EMEDIUMTYPE , ///< 124 "Wrong medium type"
171#endif
172 ecanceled = ECANCELED , ///< 125 "Operation Canceled"
173#if !defined(__APPLE__)
174 enokey = ENOKEY , ///< 126 "Required key not available"
175 ekeyexpired = EKEYEXPIRED , ///< 127 "Key has expired"
176 ekeyrevoked = EKEYREVOKED , ///< 128 "Key has been revoked"
177 ekeyrejected = EKEYREJECTED , ///< 129 "Key was rejected by service"
178#endif
179 eownerdead = EOWNERDEAD , ///< 130 "Owner died"
180 enotrecoverable = ENOTRECOVERABLE , ///< 131 "State not recoverable"
181#if !defined(__APPLE__)
182 erfkill = ERFKILL , ///< 132 "Operation not possible due to RF-kill"
183 ehwpoison = EHWPOISON , ///< 133 "Memory page has hardware error"
184#endif
185
186 #elif defined(_WIN32)
187 eperm = EPERM , ///< 1
188 enoent = ENOENT , ///< 2
189 esrch = ESRCH , ///< 3
190 eintr = EINTR , ///< 4
191 eio = EIO , ///< 5
192 enxio = ENXIO , ///< 6
193 e2Big = E2BIG , ///< 7
194 enoexec = ENOEXEC , ///< 8
195 ebadf = EBADF , ///< 9
196 echild = ECHILD , ///< 10
197 eagain = EAGAIN , ///< 11
198 enomem = ENOMEM , ///< 12
199 eacces = EACCES , ///< 13
200 efault = EFAULT , ///< 14
201 ebusy = EBUSY , ///< 16
202 eexist = EEXIST , ///< 17
203 exdev = EXDEV , ///< 18
204 enodev = ENODEV , ///< 19
205 enotdir = ENOTDIR , ///< 20
206 eisdir = EISDIR , ///< 21
207 enfile = ENFILE , ///< 23
208 emfile = EMFILE , ///< 24
209 enotty = ENOTTY , ///< 25
210 efbig = EFBIG , ///< 27
211 enospc = ENOSPC , ///< 28
212 espipe = ESPIPE , ///< 29
213 erofs = EROFS , ///< 30
214 emlink = EMLINK , ///< 31
215 epipe = EPIPE , ///< 32
216 edom = EDOM , ///< 33
217 edeadlk = EDEADLK , ///< 36
218 enametoolong = ENAMETOOLONG , ///< 38
219 enolck = ENOLCK , ///< 39
220 enosys = ENOSYS , ///< 40
221 enotempty = ENOTEMPTY , ///< 41
222 einval = EINVAL , ///< 22
223 erange = ERANGE , ///< 34
224 eilseq = EILSEQ , ///< 42
225 struncate = STRUNCATE , ///< 80
226 eaddrinuse = EADDRINUSE , ///< 100
227 eaddrnotavail = EADDRNOTAVAIL , ///< 101
228 eafnosupport = EAFNOSUPPORT , ///< 102
229 ealready = EALREADY , ///< 103
230 ebadmsg = EBADMSG , ///< 104
231 ecanceled = ECANCELED , ///< 105
232 econnaborted = ECONNABORTED , ///< 106
233 econnrefused = ECONNREFUSED , ///< 107
234 econnreset = ECONNRESET , ///< 108
235 edestaddrreq = EDESTADDRREQ , ///< 109
236 ehostunreach = EHOSTUNREACH , ///< 110
237 eidrm = EIDRM , ///< 111
238 einprogress = EINPROGRESS , ///< 112
239 eisconn = EISCONN , ///< 113
240 eloop = ELOOP , ///< 114
241 emsgsize = EMSGSIZE , ///< 115
242 enetdown = ENETDOWN , ///< 116
243 enetreset = ENETRESET , ///< 117
244 enetunreach = ENETUNREACH , ///< 118
245 enobufs = ENOBUFS , ///< 119
246 enodata = ENODATA , ///< 120
247 enolink = ENOLINK , ///< 121
248 enomsg = ENOMSG , ///< 122
249 enoprotoopt = ENOPROTOOPT , ///< 123
250 enosr = ENOSR , ///< 124
251 enostr = ENOSTR , ///< 125
252 enotconn = ENOTCONN , ///< 126
253 enotrecoverable = ENOTRECOVERABLE , ///< 127
254 enotsock = ENOTSOCK , ///< 128
255 enotsup = ENOTSUP , ///< 129
256 eopnotsupp = EOPNOTSUPP , ///< 130
257
258 #if !defined(_WIN32)
259 eother = EOTHER , ///< 131
260 #else
261 eother = 131 , ///< 131
262 #endif
263 eoverflow = EOVERFLOW , ///< 132
264 eownerdead = EOWNERDEAD , ///< 133
265 eproto = EPROTO , ///< 134
266 eprotonosupport = EPROTONOSUPPORT , ///< 135
267 eprototype = EPROTOTYPE , ///< 136
268 etime = ETIME , ///< 137
269 etimedout = ETIMEDOUT , ///< 138
270 etxtbsy = ETXTBSY , ///< 139
271 ewouldblock = EWOULDBLOCK , ///< 140
272 #endif
273};
274
275//==================================================================================================
276/// Denotes exceptions thrown by classes of namespace \ref alib::lang::system.
277//==================================================================================================
279{
280 /// Everything is fine.
281 OK,
282};
283
284/// Namespace function that creates an according \alib{lang;Exception} to a corresponding
285/// system error number.
286///
287/// The small challenge here is that arbitrary error numbers (of an unknown) type might occur, that
288/// do not have a corresponding enum record. \alib{lang::system;SystemErrors;SystemErrors::UNKNOWN}
289/// is thrown and only the number is displayed in the description text.
290///
291/// @param ci The source location of the exception creation.
292/// @param errNo The system's error number.
293/// @return An exception object.
295 CreateSystemException( const CallerInfo& ci, int errNo );
296
297
298} // namespace alib[:: lang::system]
299
300/// Type alias in namespace \b alib.
302
303} // namespace [alib]
304
305#endif // HPP_ALIB_LANG_SYSTEM_ERRORS
306
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:223
#define ALIB_API
Definition alib.hpp:639
Exception CreateSystemException(const CallerInfo &ci, int errNo)
SystemExceptions
Denotes exceptions thrown by classes of namespace alib::lang::system.
SystemErrors
Denotes result values returned by system functions (glibc, etc).
@ None
No Error (alias for OK)
Definition alib.cpp:69