better display of thrown errors

This commit is contained in:
Joey Hess 2011-07-05 14:58:33 -04:00
parent 82eb082ab9
commit d31b84c777
4 changed files with 15 additions and 5 deletions

View file

@ -96,10 +96,15 @@ prepCommand Command { cmdseek = seek } params = do
doCommand :: CommandStart -> CommandCleanup
doCommand = start
where
start = stage $ maybe (return True) perform
perform = stage $ maybe (showEndFail >> return False) cleanup
start = stage $ maybe success perform
perform = stage $ maybe failure cleanup
cleanup = stage $ \r -> showEndResult r >> return r
stage a b = b >>= a
success = return True
failure = do
showProgress
showEndFail
return False
notAnnexed :: FilePath -> Annex (Maybe a) -> Annex (Maybe a)
notAnnexed file a = maybe a (const $ return Nothing) =<< Backend.lookupFile file