xref: /netbsd-src/external/mit/libuv/dist/docs/src/errors.rst (revision 82d56013d7b633d116a93943de88e08335357a7c)
1
2.. _errors:
3
4Error handling
5==============
6
7In libuv errors are negative numbered constants. As a rule of thumb, whenever
8there is a status parameter, or an API functions returns an integer, a negative
9number will imply an error.
10
11When a function which takes a callback returns an error, the callback will never
12be 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
19Error 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_EPERM
255
256    operation not permitted
257
258.. c:macro:: UV_EPIPE
259
260    broken pipe
261
262.. c:macro:: UV_EPROTO
263
264    protocol error
265
266.. c:macro:: UV_EPROTONOSUPPORT
267
268    protocol not supported
269
270.. c:macro:: UV_EPROTOTYPE
271
272    protocol wrong type for socket
273
274.. c:macro:: UV_ERANGE
275
276    result too large
277
278.. c:macro:: UV_EROFS
279
280    read-only file system
281
282.. c:macro:: UV_ESHUTDOWN
283
284    cannot send after transport endpoint shutdown
285
286.. c:macro:: UV_ESPIPE
287
288    invalid seek
289
290.. c:macro:: UV_ESRCH
291
292    no such process
293
294.. c:macro:: UV_ETIMEDOUT
295
296    connection timed out
297
298.. c:macro:: UV_ETXTBSY
299
300    text file is busy
301
302.. c:macro:: UV_EXDEV
303
304    cross-device link not permitted
305
306.. c:macro:: UV_UNKNOWN
307
308    unknown error
309
310.. c:macro:: UV_EOF
311
312    end of file
313
314.. c:macro:: UV_ENXIO
315
316    no such device or address
317
318.. c:macro:: UV_EMLINK
319
320    too many links
321
322
323API
324---
325
326.. c:function:: UV_ERRNO_MAP(iter_macro)
327
328    Macro that expands to a series of invocations of `iter_macro` for
329    each of the error constants above. `iter_macro` is invoked with two
330    arguments: the name of the error constant without the `UV_` prefix,
331    and the error message string literal.
332
333.. c:function:: const char* uv_strerror(int err)
334
335    Returns the error message for the given error code.  Leaks a few bytes
336    of memory when you call it with an unknown error code.
337
338.. c:function:: char* uv_strerror_r(int err, char* buf, size_t buflen)
339
340    Returns the error message for the given error code. The zero-terminated
341    message is stored in the user-supplied buffer `buf` of at most `buflen` bytes.
342
343    .. versionadded:: 1.22.0
344
345.. c:function:: const char* uv_err_name(int err)
346
347    Returns the error name for the given error code.  Leaks a few bytes
348    of memory when you call it with an unknown error code.
349
350.. c:function:: char* uv_err_name_r(int err, char* buf, size_t buflen)
351
352    Returns the error name for the given error code. The zero-terminated
353    name is stored in the user-supplied buffer `buf` of at most `buflen` bytes.
354
355    .. versionadded:: 1.22.0
356
357.. c:function:: int uv_translate_sys_error(int sys_errno)
358
359   Returns the libuv error code equivalent to the given platform dependent error
360   code: POSIX error codes on Unix (the ones stored in `errno`), and Win32 error
361   codes on Windows (those returned by `GetLastError()` or `WSAGetLastError()`).
362
363   If `sys_errno` is already a libuv error, it is simply returned.
364
365   .. versionchanged:: 1.10.0 function declared public.
366