catch whereisKey exception and provide error messages when external programs neglect to

* whereis: If a remote fails to report on urls where a key
  is located, display a warning, rather than giving up and not displaying
  any information.
* When external special remotes fail but neglect to provide an error
  message, say what request failed, which is better than displaying an
  empty error message to the user.
This commit is contained in:
Joey Hess 2020-02-27 14:09:18 -04:00
parent bb20c16cf0
commit 2366e7fb84
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 41 additions and 13 deletions

View file

@ -92,7 +92,18 @@ getRemoteUrls key remote
<$> askremote
<*> claimedurls
where
askremote = maybe (pure []) (flip id key) (whereisKey remote)
askremote = case whereisKey remote of
Nothing -> pure []
Just w -> tryNonAsync (w key) >>= \case
Right l -> pure l
Left e -> do
warning $ unwords
[ "unable to query remote"
, name remote
, "for urls:"
, show e
]
return []
claimedurls = do
us <- map fst
. filter (\(_, d) -> d == OtherDownloader)