Context: https://github.com/notify-rs/notify/issues/266
man inotify_add_watch says:
ENOSPC The user limit on the total number of inotify watches was reached or the kernel failed to allocate a needed
resource.
The error the standard library gives for this is not very helpful for seeing what actually went wrong.
Looks more like a libc bug than a rust library one? From what I see the standard library calls strerror_r:
This is just an inherent limitation of libc and its limited number of error codes. If you wanted, you could use your own error type that has more specific messages for certain codes.
A inotify_add_watch specific fix could be done around this place, inside the inotify crate: https://github.com/hannobraun/inotify/blob/f09e1bdbcbd479d3090257e47458a19be127e29f/src/inotify.rs#L200
E.g. call raw_os_error on it, check if it matches ENOSPC, if yes, return an error with a more suiting message.
But it's better to discuss that with the inotify maintainers I think.
I don't think there's anything the standard library can do about this, notify is going to fix it on their end.
Most helpful comment
This is just an inherent limitation of libc and its limited number of error codes. If you wanted, you could use your own error type that has more specific messages for certain codes.