local-ip-address
local-ip-address copied to clipboard
Misleading error message when using non-`en0` interface on macOS
Calling local_ip()
on macOS when using e.g. en1
instead of en0
(with the latter not being assigned an IP at all) yields the following, slightly misleading error message:
PlatformNotSupported("macos")
Perhaps the library could try en0
, en1
, ... in order until it finds an IP address and, if not, throw an error along the lines of "No interface with an IP address found"?
Hi @fwcd, thanks for opening this issue!
I agree, the current error message it's confusing. Let me check on other approaches, when I updated the Linux approach to use neli I wondered if there's any similar approach for macOS that doesn't rely on interface name.
As of today errors are standardized which means that I have to keep all errors the same for supported targets, we could have complaints on match cases when building on macOS for multi target projects if I added another error message for this specialized scenario.
I think I could, research on other ways to retrieve the default gateway on macOS, and then, update the approach so we don't rely on the interface name anymore.
What do you think?