stop trapping all exceptions
Need to allow exceptions to be thrown for SIGPIPE propigation. Converted places that used error unncessarily to not.
This commit is contained in:
parent
470e0a2fbd
commit
2caf711827
2 changed files with 17 additions and 19 deletions
26
Commands.hs
26
Commands.hs
|
@ -101,21 +101,19 @@ parseCmd argv state = do
|
||||||
- the annex directory and setting up the symlink pointing to its content. -}
|
- the annex directory and setting up the symlink pointing to its content. -}
|
||||||
addCmd :: FilePath -> Annex ()
|
addCmd :: FilePath -> Annex ()
|
||||||
addCmd file = inBackend file $ do
|
addCmd file = inBackend file $ do
|
||||||
liftIO $ checkLegal file
|
s <- liftIO $ getSymbolicLinkStatus file
|
||||||
showStart "add" file
|
if ((isSymbolicLink s) || (not $ isRegularFile s))
|
||||||
g <- Annex.gitRepo
|
then return ()
|
||||||
stored <- Backend.storeFileKey file
|
else do
|
||||||
case (stored) of
|
showStart "add" file
|
||||||
Nothing -> showEndFail "no backend could store" file
|
g <- Annex.gitRepo
|
||||||
Just (key, backend) -> do
|
stored <- Backend.storeFileKey file
|
||||||
logStatus key ValuePresent
|
case (stored) of
|
||||||
setup g key
|
Nothing -> showEndFail "no backend could store" file
|
||||||
|
Just (key, backend) -> do
|
||||||
|
logStatus key ValuePresent
|
||||||
|
setup g key
|
||||||
where
|
where
|
||||||
checkLegal file = do
|
|
||||||
s <- getSymbolicLinkStatus file
|
|
||||||
if ((isSymbolicLink s) || (not $ isRegularFile s))
|
|
||||||
then error $ "not a regular file: " ++ file
|
|
||||||
else return ()
|
|
||||||
setup g key = do
|
setup g key = do
|
||||||
let dest = annexLocation g key
|
let dest = annexLocation g key
|
||||||
liftIO $ createDirectoryIfMissing True (parentDir dest)
|
liftIO $ createDirectoryIfMissing True (parentDir dest)
|
||||||
|
|
10
git-annex.hs
10
git-annex.hs
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex main program -}
|
{- git-annex main program -}
|
||||||
|
|
||||||
import Control.Exception
|
import IO (try)
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Environment
|
import System.Environment
|
||||||
|
|
||||||
|
@ -18,8 +18,9 @@ main = do
|
||||||
(flags, actions) <- parseCmd args state
|
(flags, actions) <- parseCmd args state
|
||||||
tryRun state $ [startup flags] ++ actions ++ [shutdown]
|
tryRun state $ [startup flags] ++ actions ++ [shutdown]
|
||||||
|
|
||||||
{- Runs a list of Annex actions. Catches exceptions, not stopping
|
{- Runs a list of Annex actions. Catches IO errors and continues
|
||||||
- if some error out, and propigates an overall error status at the end.
|
- (but explicitly thrown errors terminate the whole command).
|
||||||
|
- Propigates an overall error status at the end.
|
||||||
-
|
-
|
||||||
- This runs in the IO monad, not in the Annex monad. It seems that
|
- This runs in the IO monad, not in the Annex monad. It seems that
|
||||||
- exceptions can only be caught in the IO monad, not in a stacked monad;
|
- exceptions can only be caught in the IO monad, not in a stacked monad;
|
||||||
|
@ -29,8 +30,7 @@ main = do
|
||||||
tryRun :: AnnexState -> [Annex ()] -> IO ()
|
tryRun :: AnnexState -> [Annex ()] -> IO ()
|
||||||
tryRun state actions = tryRun' state 0 actions
|
tryRun state actions = tryRun' state 0 actions
|
||||||
tryRun' state errnum (a:as) = do
|
tryRun' state errnum (a:as) = do
|
||||||
result <- try
|
result <- try $ Annex.run state a
|
||||||
(Annex.run state a)::IO (Either SomeException ((), AnnexState))
|
|
||||||
case (result) of
|
case (result) of
|
||||||
Left err -> do
|
Left err -> do
|
||||||
showErr err
|
showErr err
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue