zpp
Zephyr C++20 Framework
error_code.hpp
Go to the documentation of this file.
1 
7 #ifndef ZPP_INCLUDE_ZPP_ERROR_CODE_HPP
8 #define ZPP_INCLUDE_ZPP_ERROR_CODE_HPP
9 
10 #include <zephyr/kernel.h>
11 #include <zephyr/sys/__assert.h>
12 #include <errno.h>
13 
14 namespace zpp {
15 
19 enum class error_code {
20  k_perm = EPERM,
21  k_noent = ENOENT,
22  k_srch = ESRCH,
23  k_intr = EINTR,
24  k_io = EIO,
25  k_nxio = ENXIO,
26  k_2big = E2BIG,
27  k_noexec = ENOEXEC,
28  k_badf = EBADF,
29  k_child = ECHILD,
30  k_again = EAGAIN,
31  k_nomem = ENOMEM,
32  k_acces = EACCES,
33  k_fault = EFAULT,
34  k_notblk = ENOTBLK,
35  k_busy = EBUSY,
36  k_exits = EEXIST,
37  k_xdev = EXDEV,
38  k_nodev = ENODEV,
39  k_notdir = ENOTDIR,
40  k_isdir = EISDIR,
41  k_inval = EINVAL,
42  k_nfile = ENFILE,
43  k_mfile = EMFILE,
44  k_notty = ENOTTY,
45  k_txtbsy = ETXTBSY,
46  k_fbig = EFBIG,
47  k_nospc = ENOSPC,
48  k_spipe = ESPIPE,
49  k_rofs = EROFS,
50  k_mlink = EMLINK,
51  k_pipe = EPIPE,
52  k_dom = EDOM,
53  k_range = ERANGE,
54  k_nomsg = ENOMSG,
55  k_deadlk = EDEADLK,
56  k_nolck = ENOLCK,
57  k_nostr = ENOSTR,
58  k_nodata = ENODATA,
59  k_time = ETIME,
60  k_nosr = ENOSR,
61  k_proto = EPROTO,
62  k_badmsg = EBADMSG,
63  k_nosys = ENOSYS,
64  k_notempty = ENOTEMPTY,
65  k_nametoolong = ENAMETOOLONG,
66  k_loop = ELOOP,
67  k_opnotsupp = EOPNOTSUPP,
68  k_pfnosupport = EPFNOSUPPORT,
69  k_connreset = ECONNRESET,
70  k_nobufs = ENOBUFS,
71  k_afnosupport = EAFNOSUPPORT,
72  k_prototype = EPROTOTYPE,
73  k_notsock = ENOTSOCK,
74  k_noprotoopt = ENOPROTOOPT,
75  k_shutdown = ESHUTDOWN,
76  k_connrefused = ECONNREFUSED,
77  k_addrinuse = EADDRINUSE,
78  k_connaborted = ECONNABORTED,
79  k_netunreach = ENETUNREACH,
80  k_netdown = ENETDOWN,
81  k_timeout = ETIMEDOUT,
82  k_hostdown = EHOSTDOWN,
83  k_hostunreach = EHOSTUNREACH,
84  k_inprogress = EINPROGRESS,
85  k_already = EALREADY,
86  k_destaddrreq = EDESTADDRREQ,
87  k_msgsize = EMSGSIZE,
88  k_protonosupport = EPROTONOSUPPORT,
89  k_socktnosupport = ESOCKTNOSUPPORT,
90  k_addrnotavail = EADDRNOTAVAIL,
91  k_netreset = ENETRESET,
92  k_isconn = EISCONN,
93  k_notconn = ENOTCONN,
94  k_toomanyrefs = ETOOMANYREFS,
95  k_notsup = ENOTSUP,
96  k_ilseq = EILSEQ,
97  k_overflow = EOVERFLOW,
98  k_canceled = ECANCELED,
99  k_wouldblock = EWOULDBLOCK,
100 };
101 
102 constexpr error_code to_error_code(int v) noexcept
103 {
104  return static_cast<error_code>(v);
105 }
106 
107 static_assert(error_code::k_perm == to_error_code(EPERM));
108 static_assert(error_code::k_wouldblock == to_error_code(EWOULDBLOCK));
109 
110 } // namespace zpp
111 
112 #endif // ZPP_INCLUDE_ZPP_ERROR_CODE_HPP
constexpr error_code to_error_code(int v) noexcept
Definition: error_code.hpp:102
error_code
enum with zephyr error codes
Definition: error_code.hpp:19
@ k_again
No more contexts.
@ k_canceled
Operation canceled.
@ k_toomanyrefs
Too many references: can’t splice.
@ k_wouldblock
Operation would block.
@ k_notsup
Unsupported value.
@ k_time
STREAMS timeout occurred.
@ k_inval
Invalid argument.
@ k_netreset
Network dropped connection on reset.
@ k_protonosupport
Protocol not supported.
@ k_xdev
Cross-device link.
@ k_pipe
Broken pipe.
@ k_shutdown
Can’t send after socket shutdown.
@ k_busy
Mount device busy.
@ k_dom
Argument too large.
@ k_badf
Bad file number.
@ k_exits
File exists.
@ k_nostr
STREAMS device required.
@ k_nolck
No locks available.
@ k_ilseq
Illegal byte sequence.
@ k_nametoolong
File name too long.
@ k_hostunreach
No route to host.
@ k_notty
Not a typewriter.
@ k_nfile
File table overflow.
@ k_badmsg
Invalid STREAMS message.
@ k_range
Result too large.
@ k_isconn
Socket is already connected.
@ k_addrnotavail
Can’t assign requested address.
@ k_opnotsupp
Operation not supported on socket.
@ k_intr
Interrupted system call.
@ k_proto
Generic STREAMS error.
@ k_nosr
Insufficient memory.
@ k_deadlk
Resource deadlock avoided.
@ k_fault
Bad address.
@ k_nomsg
Unexpected message type.
@ k_prototype
Protocol wrong type for socket.
@ k_notsock
Socket operation on non-socket.
@ k_msgsize
Message size.
@ k_noexec
Exec format error.
@ k_child
No children.
@ k_already
Operation already in progress.
@ k_notblk
Block device required.
@ k_txtbsy
Text file busy.
@ k_overflow
Value overflow.
@ k_perm
Not owner.
@ k_socktnosupport
Socket type not supported.
@ k_2big
Arg list too long.
@ k_spipe
Illegal seek.
@ k_mlink
Too many links.
@ k_nospc
No space left on device.
@ k_loop
Too many levels of symbolic links.
@ k_connaborted
Software caused connection abort.
@ k_isdir
Is a directory.
@ k_afnosupport
Addr family not supported.
@ k_connreset
Connection reset by peer.
@ k_rofs
Read-only file system.
@ k_notempty
Directory not empty.
@ k_addrinuse
Address already in use.
@ k_notdir
Not a directory.
@ k_timeout
Connection timed out.
@ k_io
I/O error.
@ k_nosys
Function not implemented.
@ k_noent
No such file or directory.
@ k_noprotoopt
Protocol not available.
@ k_nobufs
No buffer space available.
@ k_connrefused
Connection refused.
@ k_acces
Permission denied.
@ k_nodata
Missing expected message data.
@ k_nomem
Not enough core.
@ k_nxio
No such device or address.
@ k_fbig
File too large.
@ k_notconn
Socket is not connected.
@ k_hostdown
Host is down.
@ k_mfile
Too many open files.
@ k_netdown
Network is down.
@ k_netunreach
Network is unreachable.
@ k_destaddrreq
Destination address required.
@ k_nodev
No such device.
@ k_pfnosupport
Protocol family not supported.
@ k_srch
No such context.
@ k_inprogress
Operation now in progress.