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

Unix.getaddrinfo doesn't report errors #13075

Open
MisterDA opened this issue Apr 5, 2024 · 1 comment
Open

Unix.getaddrinfo doesn't report errors #13075

MisterDA opened this issue Apr 5, 2024 · 1 comment

Comments

@MisterDA
Copy link
Contributor

MisterDA commented Apr 5, 2024

getaddrinfo (POSIX, Windows) errors are not set into errno, but returned to the caller. The implementation of Unix.getaddrinfo doesn't report errors to the OCaml side and returns an empty list instead.
Errors codes returned from getaddrinfo are distinct from errno errors and likely shouldn't be mapped (contrary to, for examples, error code of the POSIX threads API). Maybe a distinct Unix.addrinfo_error exception type should be added?
Note that on POSIX platforms, if EAI_SYSTEM is returned, then errno should be checked to report system errors (not specific to getaddrinfo). This would also mean raising a Unix.unix_error in this case.
Should these two points be considered? Is introducing an exception a breaking change, frowned upon? Another option would be to failwith a string, like in Unix.map_file.

The remarks also apply to getnameinfo and related. Error reporting has been missing since the introduction of IPv6 in OCaml 21 years ago, so that's probably not a hot topic.

@hannesm
Copy link
Member

hannesm commented Apr 6, 2024

noteworthy to link to https://github.com/haesbaert/ocaml-getaddrinfo which as far as I remember does error reporting nicely.

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

No branches or pull requests

2 participants