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