Unified I/O error type #47771
Labels
design
Design of APIs or of the language itself
error handling
Handling of exceptions by Julia or the user
I/O
Involving the I/O subsystem: libuv, read, write, etc.
Julia currently throws different kinds of IO exceptions:
IOError happens when a libuv wrapper throws, and the contained error code is an libuv error code (e.g.
Base.UV_ENOENT
) while SystemError happens when a libc call fails and the code is a libc errno (e.g.Libc.ENOENT
). The fact that this difference is exposed to the user, feels like an implementation detail leaking into the upper layers of abstraction.Normally this doesn't matter much, because one is assumed to e.g. check if the path exists before performing the I/O operation. The application I'm currently dealing with however, is really racey, and to avoid TOCTOU bugs I just perform the operation and deal with the error after the fact. That works fine, except for the annoyance of having to deal with two highly similar error types. Because it's not really documented when libuv or libc are used, I end up with code like:
I haven't really put in much thought on how to solve this; probably a unified error type that isn't tied to libc/libuv?
The text was updated successfully, but these errors were encountered: