Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add error code constants #2

Merged
merged 3 commits into from
Mar 16, 2023
Merged

Conversation

mikesmithgh
Copy link
Contributor

I noticed errno is missing and added the values by running errono -ls on my Mac. I also added UNKOWN because I saw that when I inspected the uv.errno table in Neovim.

This has the same issue as constants in that the errno can change depending on the system, unix vs windows.

@Bilal2453
Copy link
Owner

I am a bit confused, as there is no such field in luv (luv.errno is nil). What is this defining exactly?

@Bilal2453
Copy link
Owner

Bilal2453 commented Mar 15, 2023

Oh right, that was a recent addition to Luv now that I think about it. I even PRed it into the docs. Hm regarding the values though I am indeed slightly concerned about system inconsistencies. I have been thinking on how to do this while:

a) Document the exact field names. (So uv.errno.something_random wouldn't show a string type.)
b) Not have to define any exact values, just that it is an integer.

Do you have any ideas how to approach that?

@Bilal2453
Copy link
Owner

I think for now we will go with something like this 3069b62. Just an alias that has all the fields. Can you do this?

Also use --- for descriptions, the description also needs to be right above the table value, like this:

---
---description here!
---
---@type uv.errno
uv.errno = {}

@mikesmithgh
Copy link
Contributor Author

Hey @Bilal2453 thanks for the response. Yep that makes total sense to me. I'll make those changes 👍

@mikesmithgh
Copy link
Contributor Author

Hey @Bilal2453 I have made the updates. I have only used this in the context of Neovim. Here is what the completion looks like after the change:

(field) uv.errno: { E2BIG: integer, EACCES: integer, EADDRINUSE: integer, EADDRNOTAVAIL: integer, EAFNOSUPPORT: integer, EAGAIN: integer, EAI_ADDRFAMILY: integer, EAI_AGAIN: integer, EAI_BADFLAGS: i...(too long)... integer } {
    E2BIG: integer,
    EACCES: integer,
    EADDRINUSE: integer,
    EADDRNOTAVAIL: integer,
    EAFNOSUPPORT: integer,
    EAGAIN: integer,
    EAI_ADDRFAMILY: integer,
    EAI_AGAIN: integer,
    EAI_BADFLAGS: integer,
    EAI_BADHINTS: integer,
    EAI_CANCELED: integer,
    EAI_FAIL: integer,
    EAI_FAMILY: integer,
    EAI_MEMORY: integer,
    EAI_NODATA: integer,
    EAI_NONAME: integer,
    EAI_OVERFLOW: integer,
    EAI_PROTOCOL: integer,
    EAI_SERVICE: integer,
    EAI_SOCKTYPE: integer,
    EALREADY: integer,
    EBADF: integer,
    EBUSY: integer,
    ECANCELED: integer,
    ECHARSET: integer,
    ECONNABORTED: integer,
    ECONNREFUSED: integer,
    ECONNRESET: integer,
    EDESTADDRREQ: integer,
    EEXIST: integer,
    EFAULT: integer,
    EFBIG: integer,
    EFTYPE: integer,
    EHOSTDOWN: integer,
    EHOSTUNREACH: integer,
    EILSEQ: integer,
    EINTR: integer,
    EINVAL: integer,
    EIO: integer,
    EISCONN: integer,
    EISDIR: integer,
    ELOOP: integer,
    EMFILE: integer,
    EMLINK: integer,
    EMSGSIZE: integer,
    ENAMETOOLONG: integer,
    ENETDOWN: integer,
    ENETUNREACH: integer,
    ENFILE: integer,
    ENOBUFS: integer,
    ...(+33)
}

A table value which exposes error constants as a map, where the key is the
error name (without the `UV_` prefix) and its value is a negative number.
See Libuv's "Error constants" page for further details.
(https://docs.libuv.org/en/v1.x/errors.html#error-constants)

Note: Implementation detail: on Unix error codes are the negated errno (or -errno),
while on Windows they are defined by libuv to arbitrary negative numbers.

I also removed some values, and used the values from lua print(vim.inspect(vim.loop.errno))

 | Messages: {
  E2BIG = -7,
  EACCES = -13,
  EADDRINUSE = -48,
  EADDRNOTAVAIL = -49,
  EAFNOSUPPORT = -47,
  EAGAIN = -35,
  EAI_ADDRFAMILY = -3000,
  EAI_AGAIN = -3001,
  EAI_BADFLAGS = -3002,
  EAI_BADHINTS = -3013,
  EAI_CANCELED = -3003,
  EAI_FAIL = -3004,
  EAI_FAMILY = -3005,
  EAI_MEMORY = -3006,
  EAI_NODATA = -3007,
  EAI_NONAME = -3008,
  EAI_OVERFLOW = -3009,
  EAI_PROTOCOL = -3014,
  EAI_SERVICE = -3010,
  EAI_SOCKTYPE = -3011,
  EALREADY = -37,
  EBADF = -9,
  EBUSY = -16,
  ECANCELED = -89,
  ECHARSET = -4080,
  ECONNABORTED = -53,
  ECONNREFUSED = -61,
  ECONNRESET = -54,
  EDESTADDRREQ = -39,
  EEXIST = -17,
  EFAULT = -14,
  EFBIG = -27,
  EFTYPE = -79,
  EHOSTDOWN = -64,
  EHOSTUNREACH = -65,
  EILSEQ = -92,
  EINTR = -4,
  EINVAL = -22,
  EIO = -5,
  EISCONN = -56,
  EISDIR = -21,
  ELOOP = -62,
  EMFILE = -24,
  EMLINK = -31,
  EMSGSIZE = -40,
  ENAMETOOLONG = -63,
  ENETDOWN = -50,
  ENETUNREACH = -51,
  ENFILE = -23,
  ENOBUFS = -55,
  ENODATA = -96,
  ENODEV = -19,
  ENOENT = -2,
  ENOMEM = -12,
  ENONET = -4056,
  ENOPROTOOPT = -42,
  ENOSPC = -28,
  ENOSYS = -78,
  ENOTCONN = -57,
  ENOTDIR = -20,
  ENOTEMPTY = -66,
  ENOTSOCK = -38,
  ENOTSUP = -45,
  ENOTTY = -25,
  ENXIO = -6,
  EOF = -4095,
  EOVERFLOW = -84,
  EPERM = -1,
  EPIPE = -32,
  EPROTO = -100,
  EPROTONOSUPPORT = -43,
  EPROTOTYPE = -41,
  ERANGE = -34,
  EREMOTEIO = -4030,
  EROFS = -30,
  ESHUTDOWN = -58,
  ESOCKTNOSUPPORT = -44,
  ESPIPE = -29,
  ESRCH = -3,
  ETIMEDOUT = -60,
  ETXTBSY = -26,
  EXDEV = -18,
  UNKNOWN = -4094
}

Let me know what you think

@Bilal2453 Bilal2453 merged commit a78439c into Bilal2453:main Mar 16, 2023
@Bilal2453
Copy link
Owner

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants