|
160
|
1
|
|
|
2 .. _errors:
|
|
|
3
|
|
|
4 Error handling
|
|
|
5 ==============
|
|
|
6
|
|
|
7 In libuv errors are negative numbered constants. As a rule of thumb, whenever
|
|
|
8 there is a status parameter, or an API functions returns an integer, a negative
|
|
|
9 number will imply an error.
|
|
|
10
|
|
|
11 When a function which takes a callback returns an error, the callback will never
|
|
|
12 be called.
|
|
|
13
|
|
|
14 .. note::
|
|
|
15 Implementation detail: on Unix error codes are the negated `errno` (or `-errno`), while on
|
|
|
16 Windows they are defined by libuv to arbitrary negative numbers.
|
|
|
17
|
|
|
18
|
|
|
19 Error constants
|
|
|
20 ---------------
|
|
|
21
|
|
|
22 .. c:macro:: UV_E2BIG
|
|
|
23
|
|
|
24 argument list too long
|
|
|
25
|
|
|
26 .. c:macro:: UV_EACCES
|
|
|
27
|
|
|
28 permission denied
|
|
|
29
|
|
|
30 .. c:macro:: UV_EADDRINUSE
|
|
|
31
|
|
|
32 address already in use
|
|
|
33
|
|
|
34 .. c:macro:: UV_EADDRNOTAVAIL
|
|
|
35
|
|
|
36 address not available
|
|
|
37
|
|
|
38 .. c:macro:: UV_EAFNOSUPPORT
|
|
|
39
|
|
|
40 address family not supported
|
|
|
41
|
|
|
42 .. c:macro:: UV_EAGAIN
|
|
|
43
|
|
|
44 resource temporarily unavailable
|
|
|
45
|
|
|
46 .. c:macro:: UV_EAI_ADDRFAMILY
|
|
|
47
|
|
|
48 address family not supported
|
|
|
49
|
|
|
50 .. c:macro:: UV_EAI_AGAIN
|
|
|
51
|
|
|
52 temporary failure
|
|
|
53
|
|
|
54 .. c:macro:: UV_EAI_BADFLAGS
|
|
|
55
|
|
|
56 bad ai_flags value
|
|
|
57
|
|
|
58 .. c:macro:: UV_EAI_BADHINTS
|
|
|
59
|
|
|
60 invalid value for hints
|
|
|
61
|
|
|
62 .. c:macro:: UV_EAI_CANCELED
|
|
|
63
|
|
|
64 request canceled
|
|
|
65
|
|
|
66 .. c:macro:: UV_EAI_FAIL
|
|
|
67
|
|
|
68 permanent failure
|
|
|
69
|
|
|
70 .. c:macro:: UV_EAI_FAMILY
|
|
|
71
|
|
|
72 ai_family not supported
|
|
|
73
|
|
|
74 .. c:macro:: UV_EAI_MEMORY
|
|
|
75
|
|
|
76 out of memory
|
|
|
77
|
|
|
78 .. c:macro:: UV_EAI_NODATA
|
|
|
79
|
|
|
80 no address
|
|
|
81
|
|
|
82 .. c:macro:: UV_EAI_NONAME
|
|
|
83
|
|
|
84 unknown node or service
|
|
|
85
|
|
|
86 .. c:macro:: UV_EAI_OVERFLOW
|
|
|
87
|
|
|
88 argument buffer overflow
|
|
|
89
|
|
|
90 .. c:macro:: UV_EAI_PROTOCOL
|
|
|
91
|
|
|
92 resolved protocol is unknown
|
|
|
93
|
|
|
94 .. c:macro:: UV_EAI_SERVICE
|
|
|
95
|
|
|
96 service not available for socket type
|
|
|
97
|
|
|
98 .. c:macro:: UV_EAI_SOCKTYPE
|
|
|
99
|
|
|
100 socket type not supported
|
|
|
101
|
|
|
102 .. c:macro:: UV_EALREADY
|
|
|
103
|
|
|
104 connection already in progress
|
|
|
105
|
|
|
106 .. c:macro:: UV_EBADF
|
|
|
107
|
|
|
108 bad file descriptor
|
|
|
109
|
|
|
110 .. c:macro:: UV_EBUSY
|
|
|
111
|
|
|
112 resource busy or locked
|
|
|
113
|
|
|
114 .. c:macro:: UV_ECANCELED
|
|
|
115
|
|
|
116 operation canceled
|
|
|
117
|
|
|
118 .. c:macro:: UV_ECHARSET
|
|
|
119
|
|
|
120 invalid Unicode character
|
|
|
121
|
|
|
122 .. c:macro:: UV_ECONNABORTED
|
|
|
123
|
|
|
124 software caused connection abort
|
|
|
125
|
|
|
126 .. c:macro:: UV_ECONNREFUSED
|
|
|
127
|
|
|
128 connection refused
|
|
|
129
|
|
|
130 .. c:macro:: UV_ECONNRESET
|
|
|
131
|
|
|
132 connection reset by peer
|
|
|
133
|
|
|
134 .. c:macro:: UV_EDESTADDRREQ
|
|
|
135
|
|
|
136 destination address required
|
|
|
137
|
|
|
138 .. c:macro:: UV_EEXIST
|
|
|
139
|
|
|
140 file already exists
|
|
|
141
|
|
|
142 .. c:macro:: UV_EFAULT
|
|
|
143
|
|
|
144 bad address in system call argument
|
|
|
145
|
|
|
146 .. c:macro:: UV_EFBIG
|
|
|
147
|
|
|
148 file too large
|
|
|
149
|
|
|
150 .. c:macro:: UV_EHOSTUNREACH
|
|
|
151
|
|
|
152 host is unreachable
|
|
|
153
|
|
|
154 .. c:macro:: UV_EINTR
|
|
|
155
|
|
|
156 interrupted system call
|
|
|
157
|
|
|
158 .. c:macro:: UV_EINVAL
|
|
|
159
|
|
|
160 invalid argument
|
|
|
161
|
|
|
162 .. c:macro:: UV_EIO
|
|
|
163
|
|
|
164 i/o error
|
|
|
165
|
|
|
166 .. c:macro:: UV_EISCONN
|
|
|
167
|
|
|
168 socket is already connected
|
|
|
169
|
|
|
170 .. c:macro:: UV_EISDIR
|
|
|
171
|
|
|
172 illegal operation on a directory
|
|
|
173
|
|
|
174 .. c:macro:: UV_ELOOP
|
|
|
175
|
|
|
176 too many symbolic links encountered
|
|
|
177
|
|
|
178 .. c:macro:: UV_EMFILE
|
|
|
179
|
|
|
180 too many open files
|
|
|
181
|
|
|
182 .. c:macro:: UV_EMSGSIZE
|
|
|
183
|
|
|
184 message too long
|
|
|
185
|
|
|
186 .. c:macro:: UV_ENAMETOOLONG
|
|
|
187
|
|
|
188 name too long
|
|
|
189
|
|
|
190 .. c:macro:: UV_ENETDOWN
|
|
|
191
|
|
|
192 network is down
|
|
|
193
|
|
|
194 .. c:macro:: UV_ENETUNREACH
|
|
|
195
|
|
|
196 network is unreachable
|
|
|
197
|
|
|
198 .. c:macro:: UV_ENFILE
|
|
|
199
|
|
|
200 file table overflow
|
|
|
201
|
|
|
202 .. c:macro:: UV_ENOBUFS
|
|
|
203
|
|
|
204 no buffer space available
|
|
|
205
|
|
|
206 .. c:macro:: UV_ENODEV
|
|
|
207
|
|
|
208 no such device
|
|
|
209
|
|
|
210 .. c:macro:: UV_ENOENT
|
|
|
211
|
|
|
212 no such file or directory
|
|
|
213
|
|
|
214 .. c:macro:: UV_ENOMEM
|
|
|
215
|
|
|
216 not enough memory
|
|
|
217
|
|
|
218 .. c:macro:: UV_ENONET
|
|
|
219
|
|
|
220 machine is not on the network
|
|
|
221
|
|
|
222 .. c:macro:: UV_ENOPROTOOPT
|
|
|
223
|
|
|
224 protocol not available
|
|
|
225
|
|
|
226 .. c:macro:: UV_ENOSPC
|
|
|
227
|
|
|
228 no space left on device
|
|
|
229
|
|
|
230 .. c:macro:: UV_ENOSYS
|
|
|
231
|
|
|
232 function not implemented
|
|
|
233
|
|
|
234 .. c:macro:: UV_ENOTCONN
|
|
|
235
|
|
|
236 socket is not connected
|
|
|
237
|
|
|
238 .. c:macro:: UV_ENOTDIR
|
|
|
239
|
|
|
240 not a directory
|
|
|
241
|
|
|
242 .. c:macro:: UV_ENOTEMPTY
|
|
|
243
|
|
|
244 directory not empty
|
|
|
245
|
|
|
246 .. c:macro:: UV_ENOTSOCK
|
|
|
247
|
|
|
248 socket operation on non-socket
|
|
|
249
|
|
|
250 .. c:macro:: UV_ENOTSUP
|
|
|
251
|
|
|
252 operation not supported on socket
|
|
|
253
|
|
|
254 .. c:macro:: UV_EOVERFLOW
|
|
|
255
|
|
|
256 value too large for defined data type
|
|
|
257
|
|
|
258 .. c:macro:: UV_EPERM
|
|
|
259
|
|
|
260 operation not permitted
|
|
|
261
|
|
|
262 .. c:macro:: UV_EPIPE
|
|
|
263
|
|
|
264 broken pipe
|
|
|
265
|
|
|
266 .. c:macro:: UV_EPROTO
|
|
|
267
|
|
|
268 protocol error
|
|
|
269
|
|
|
270 .. c:macro:: UV_EPROTONOSUPPORT
|
|
|
271
|
|
|
272 protocol not supported
|
|
|
273
|
|
|
274 .. c:macro:: UV_EPROTOTYPE
|
|
|
275
|
|
|
276 protocol wrong type for socket
|
|
|
277
|
|
|
278 .. c:macro:: UV_ERANGE
|
|
|
279
|
|
|
280 result too large
|
|
|
281
|
|
|
282 .. c:macro:: UV_EROFS
|
|
|
283
|
|
|
284 read-only file system
|
|
|
285
|
|
|
286 .. c:macro:: UV_ESHUTDOWN
|
|
|
287
|
|
|
288 cannot send after transport endpoint shutdown
|
|
|
289
|
|
|
290 .. c:macro:: UV_ESPIPE
|
|
|
291
|
|
|
292 invalid seek
|
|
|
293
|
|
|
294 .. c:macro:: UV_ESRCH
|
|
|
295
|
|
|
296 no such process
|
|
|
297
|
|
|
298 .. c:macro:: UV_ETIMEDOUT
|
|
|
299
|
|
|
300 connection timed out
|
|
|
301
|
|
|
302 .. c:macro:: UV_ETXTBSY
|
|
|
303
|
|
|
304 text file is busy
|
|
|
305
|
|
|
306 .. c:macro:: UV_EXDEV
|
|
|
307
|
|
|
308 cross-device link not permitted
|
|
|
309
|
|
|
310 .. c:macro:: UV_UNKNOWN
|
|
|
311
|
|
|
312 unknown error
|
|
|
313
|
|
|
314 .. c:macro:: UV_EOF
|
|
|
315
|
|
|
316 end of file
|
|
|
317
|
|
|
318 .. c:macro:: UV_ENXIO
|
|
|
319
|
|
|
320 no such device or address
|
|
|
321
|
|
|
322 .. c:macro:: UV_EMLINK
|
|
|
323
|
|
|
324 too many links
|
|
|
325
|
|
|
326 .. c:macro:: UV_ENOTTY
|
|
|
327
|
|
|
328 inappropriate ioctl for device
|
|
|
329
|
|
|
330 .. c:macro:: UV_EFTYPE
|
|
|
331
|
|
|
332 inappropriate file type or format
|
|
|
333
|
|
|
334 .. c:macro:: UV_EILSEQ
|
|
|
335
|
|
|
336 illegal byte sequence
|
|
|
337
|
|
|
338 .. c:macro:: UV_ESOCKTNOSUPPORT
|
|
|
339
|
|
|
340 socket type not supported
|
|
|
341
|
|
|
342 .. c:macro:: UV_EUNATCH
|
|
|
343
|
|
|
344 protocol driver not attached
|
|
|
345
|
|
|
346 API
|
|
|
347 ---
|
|
|
348
|
|
|
349 .. c:macro:: UV_ERRNO_MAP(iter_macro)
|
|
|
350
|
|
|
351 Macro that expands to a series of invocations of `iter_macro` for
|
|
|
352 each of the error constants above. `iter_macro` is invoked with two
|
|
|
353 arguments: the name of the error constant without the `UV_` prefix,
|
|
|
354 and the error message string literal.
|
|
|
355
|
|
|
356 .. c:function:: const char* uv_strerror(int err)
|
|
|
357
|
|
|
358 Returns the error message for the given error code. Leaks a few bytes
|
|
|
359 of memory when you call it with an unknown error code.
|
|
|
360
|
|
|
361 .. c:function:: char* uv_strerror_r(int err, char* buf, size_t buflen)
|
|
|
362
|
|
|
363 Returns the error message for the given error code. The zero-terminated
|
|
|
364 message is stored in the user-supplied buffer `buf` of at most `buflen` bytes.
|
|
|
365
|
|
|
366 .. versionadded:: 1.22.0
|
|
|
367
|
|
|
368 .. c:function:: const char* uv_err_name(int err)
|
|
|
369
|
|
|
370 Returns the error name for the given error code. Leaks a few bytes
|
|
|
371 of memory when you call it with an unknown error code.
|
|
|
372
|
|
|
373 .. c:function:: char* uv_err_name_r(int err, char* buf, size_t buflen)
|
|
|
374
|
|
|
375 Returns the error name for the given error code. The zero-terminated
|
|
|
376 name is stored in the user-supplied buffer `buf` of at most `buflen` bytes.
|
|
|
377
|
|
|
378 .. versionadded:: 1.22.0
|
|
|
379
|
|
|
380 .. c:function:: int uv_translate_sys_error(int sys_errno)
|
|
|
381
|
|
|
382 Returns the libuv error code equivalent to the given platform dependent error
|
|
|
383 code: POSIX error codes on Unix (the ones stored in `errno`), and Win32 error
|
|
|
384 codes on Windows (those returned by `GetLastError()` or `WSAGetLastError()`).
|
|
|
385
|
|
|
386 If `sys_errno` is already a libuv error, it is simply returned.
|
|
|
387
|
|
|
388 .. versionchanged:: 1.10.0 function declared public.
|