uerrno
– 系统错误代码
这个模块实现了相应 CPython 模块的一个子集,如下所述。有关更多信息,请参阅原始CPython文档: errno
此模块提供访问符号错误代码以进行 OSError 异常。特定的代码清单依赖于 MicroPython port.
常量
- EEXIST, EAGAIN, etc.
错误代码,基于ANSI C/POSIX标准。所有错误代码开头都有“E”。错误通常可以访问为
exc.args[0]
,其中exc
是OSError
的一个实例示例:
try: uos.mkdir("my_dir") except OSError as exc: if exc.args[0] == uerrno.EEXIST: print("Directory already exists")
- uerrno.errorcode
字典将数字错误代码映射到带有符号错误代码的字符串(参见上文):
>>> print(uerrno.errorcode[uerrno.EEXIST]) EEXIST
异常 |
值 |
描述 |
|
1 |
Operation not permitted |
|
2 |
No such file or directory |
|
3 |
No such process |
|
4 |
Interrupted system call |
|
5 |
I/O error |
|
6 |
No such device or address |
|
7 |
Argument list too long |
|
8 |
Exec format error |
|
9 |
Bad file number |
|
10 |
No child processes |
|
11 |
Try again |
|
12 |
Out of memory |
|
13 |
Permission denied |
|
14 |
Bad address |
|
15 |
Block device required |
|
16 |
Device or resource busy |
|
17 |
File exists |
|
18 |
Cross-device link |
|
19 |
No such device |
|
20 |
Not a directory |
|
21 |
Is a directory |
|
22 |
Invalid argument |
|
23 |
File table overflow |
|
24 |
Too many open files |
|
25 |
Not a typewriter |
|
26 |
Text file busy |
|
27 |
File too large |
|
28 |
No space left on device |
|
29 |
Illegal seek |
|
30 |
Read-only file system |
|
31 |
Too many links |
|
32 |
Broken pipe |
|
33 |
Math argument out of domain of func |
|
34 |
Math result not representable |
|
11 |
Operation would block |
|
95 |
Operation not supported on transport endpoint |
|
97 |
Address family not supported by protocol |
|
98 |
Address already in use |
|
99 |
Software caused connection abort |
|
104 |
Connection reset by peer |
|
105 |
No buffer space available |
|
106 |
Transport endpoint is already connected |
|
107 |
Transport endpoint is not connected |
|
110 |
Connection timed out |
|
111 |
Connection refused |
|
113 |
No route to host |
|
114 |
Operation already in progress |
|
115 |
Operation now in progress |