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
|
a
|
||||||
case result of
|
case result of
|
||||||
Left err -> do
|
Left err -> do
|
||||||
Annex.eval state $ showErr err
|
Annex.eval state $ do
|
||||||
|
showEndFail
|
||||||
|
showErr err
|
||||||
tryRun' state (errnum + 1) as
|
tryRun' state (errnum + 1) as
|
||||||
Right (True,state') -> tryRun' state' errnum as
|
Right (True,state') -> tryRun' state' errnum as
|
||||||
Right (False,state') -> tryRun' state' (errnum + 1) as
|
Right (False,state') -> tryRun' state' (errnum + 1) as
|
||||||
|
|
|
@ -96,10 +96,15 @@ prepCommand Command { cmdseek = seek } params = do
|
||||||
doCommand :: CommandStart -> CommandCleanup
|
doCommand :: CommandStart -> CommandCleanup
|
||||||
doCommand = start
|
doCommand = start
|
||||||
where
|
where
|
||||||
start = stage $ maybe (return True) perform
|
start = stage $ maybe success perform
|
||||||
perform = stage $ maybe (showEndFail >> return False) cleanup
|
perform = stage $ maybe failure cleanup
|
||||||
cleanup = stage $ \r -> showEndResult r >> return r
|
cleanup = stage $ \r -> showEndResult r >> return r
|
||||||
stage a b = b >>= a
|
stage a b = b >>= a
|
||||||
|
success = return True
|
||||||
|
failure = do
|
||||||
|
showProgress
|
||||||
|
showEndFail
|
||||||
|
return False
|
||||||
|
|
||||||
notAnnexed :: FilePath -> Annex (Maybe a) -> Annex (Maybe a)
|
notAnnexed :: FilePath -> Annex (Maybe a) -> Annex (Maybe a)
|
||||||
notAnnexed file a = maybe a (const $ return Nothing) =<< Backend.lookupFile file
|
notAnnexed file a = maybe a (const $ return Nothing) =<< Backend.lookupFile file
|
||||||
|
|
|
@ -175,6 +175,7 @@ scan r = do
|
||||||
showEndOk
|
showEndOk
|
||||||
return r'
|
return r'
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
|
showProgress
|
||||||
showEndFail
|
showEndFail
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
|
@ -43,14 +43,16 @@ showEndOk :: Annex ()
|
||||||
showEndOk = verbose $ liftIO $ putStrLn "ok"
|
showEndOk = verbose $ liftIO $ putStrLn "ok"
|
||||||
|
|
||||||
showEndFail :: Annex ()
|
showEndFail :: Annex ()
|
||||||
showEndFail = verbose $ liftIO $ putStrLn "\nfailed"
|
showEndFail = verbose $ liftIO $ putStrLn "failed"
|
||||||
|
|
||||||
showEndResult :: Bool -> Annex ()
|
showEndResult :: Bool -> Annex ()
|
||||||
showEndResult True = showEndOk
|
showEndResult True = showEndOk
|
||||||
showEndResult False = showEndFail
|
showEndResult False = showEndFail
|
||||||
|
|
||||||
showErr :: (Show a) => a -> Annex ()
|
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 :: String -> Annex ()
|
||||||
warning w = do
|
warning w = do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue