From 3210c9e30058cdf8362299f4e48b1cede7e4652a Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Wed, 23 Oct 2019 00:57:06 +1000 Subject: [PATCH] Fix HostPreference error handling on macOS --- lib/core/src/Cardano/Wallet/Api/Server.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/core/src/Cardano/Wallet/Api/Server.hs b/lib/core/src/Cardano/Wallet/Api/Server.hs index 3ad36d22c08..fe7fed04dad 100644 --- a/lib/core/src/Cardano/Wallet/Api/Server.hs +++ b/lib/core/src/Cardano/Wallet/Api/Server.hs @@ -347,14 +347,21 @@ data ListenError ioToListenError :: HostPreference -> Listen -> IOException -> Maybe ListenError ioToListenError hostPreference portOpt e + -- A socket is already listening on that address and port | isAlreadyInUseError e = Just (ListenErrorAddressAlreadyInUse (listenPort portOpt)) + -- Usually caused by trying to listen on a privileged port | isPermissionError e = Just ListenErrorOperationNotPermitted + -- Bad hostname | isDoesNotExistError e = Just (ListenErrorHostDoesNotExist hostPreference) + -- Address is valid, but can't be used for listening -- Linux | show (ioeGetErrorType e) == "invalid argument" = Just (ListenErrorInvalidAddress hostPreference) + -- Address is valid, but can't be used for listening -- Darwin + | show (ioeGetErrorType e) == "unsupported operation" = + Just (ListenErrorInvalidAddress hostPreference) | otherwise = Nothing where