diff options
author | Joey Hess <joey@kitenet.net> | 2011-11-10 20:24:24 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-11-10 20:57:28 -0400 |
commit | 49d2177d51b95b4a01c05ee07e166e93751b4c51 (patch) | |
tree | b818865e5a924dc90bf0a79608351b1aeffe458a /Remote/Git.hs | |
parent | a71c03bc5162916853ff520d5c7c89e849c6a047 (diff) |
factored out some useful error catching methods
Diffstat (limited to 'Remote/Git.hs')
-rw-r--r-- | Remote/Git.hs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs index b63a8f124..30d992e8c 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -134,11 +134,7 @@ inAnnex r key | Git.repoIsUrl r = checkremote | otherwise = checklocal where - checkhttp = dispatch <$> check - where - check = safely $ Url.exists $ keyUrl r key - dispatch (Left e) = Left $ show e - dispatch (Right v) = Right v + checkhttp = liftIO $ catchMsgIO $ Url.exists $ keyUrl r key checkremote = do showAction $ "checking " ++ Git.repoDescribe r onRemote r (check, unknown) "inannex" [Param (show key)] @@ -149,13 +145,11 @@ inAnnex r key dispatch _ = unknown checklocal = dispatch <$> check where - check = safely $ onLocal r $ + check = liftIO $ catchMsgIO $ onLocal r $ Annex.Content.inAnnexSafe key - dispatch (Left e) = Left $ show e + dispatch (Left e) = Left e dispatch (Right (Just b)) = Right b dispatch (Right Nothing) = unknown - safely :: IO a -> Annex (Either IOException a) - safely a = liftIO $ try a unknown = Left $ "unable to check " ++ Git.repoDescribe r {- Runs an action on a local repository inexpensively, by making an annex |