better display of thrown errors
This commit is contained in:
parent
82eb082ab9
commit
d31b84c777
4 changed files with 15 additions and 5 deletions
|
@ -87,7 +87,9 @@ tryRun' state errnum (a:as) = do
|
|||
a
|
||||
case result of
|
||||
Left err -> do
|
||||
Annex.eval state $ showErr err
|
||||
Annex.eval state $ do
|
||||
showEndFail
|
||||
showErr err
|
||||
tryRun' state (errnum + 1) as
|
||||
Right (True,state') -> tryRun' state' errnum as
|
||||
Right (False,state') -> tryRun' state' (errnum + 1) as
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -175,6 +175,7 @@ scan r = do
|
|||
showEndOk
|
||||
return r'
|
||||
Nothing -> do
|
||||
showProgress
|
||||
showEndFail
|
||||
return r
|
||||
|
||||
|
|
|
@ -43,14 +43,16 @@ showEndOk :: Annex ()
|
|||
showEndOk = verbose $ liftIO $ putStrLn "ok"
|
||||
|
||||
showEndFail :: Annex ()
|
||||
showEndFail = verbose $ liftIO $ putStrLn "\nfailed"
|
||||
showEndFail = verbose $ liftIO $ putStrLn "failed"
|
||||
|
||||
showEndResult :: Bool -> Annex ()
|
||||
showEndResult True = showEndOk
|
||||
showEndResult False = showEndFail
|
||||
|
||||
showErr :: (Show a) => a -> Annex ()
|
||||
showErr e = warning $ "git-annex: " ++ show e
|
||||
showErr e = do
|
||||
liftIO $ hFlush stdout
|
||||
liftIO $ hPutStrLn stderr $ "git-annex: " ++ show e
|
||||
|
||||
warning :: String -> Annex ()
|
||||
warning w = do
|
||||
|
|
Loading…
Reference in a new issue