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