Skip to content

Commit

Permalink
Fix HostPreference error handling on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Oct 22, 2019
1 parent 12fb6be commit d25adc6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d25adc6

Please sign in to comment.