aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-07-26 23:01:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-07-26 23:01:44 -0400
commit0950b8314a21e125aec383db078afc648bd4444e (patch)
tree59a37c2d90e73dfcbcb21e2dcc15e83f7e80715e
parent51a6a833c5e07d8ac57ab8857c649669502d9f6b (diff)
better exception display
-rw-r--r--Assistant/Threads/Watcher.hs2
-rw-r--r--Remote/Directory.hs4
-rw-r--r--Remote/Helper/Chunked.hs6
-rw-r--r--Remote/Helper/Chunked/Legacy.hs4
-rw-r--r--Remote/WebDAV.hs2
5 files changed, 10 insertions, 8 deletions
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs
index 0ed1bd22f..91e0fc619 100644
--- a/Assistant/Threads/Watcher.hs
+++ b/Assistant/Threads/Watcher.hs
@@ -184,7 +184,7 @@ runHandler :: Handler -> FilePath -> Maybe FileStatus -> Assistant ()
runHandler handler file filestatus = void $ do
r <- tryIO <~> handler (normalize file) filestatus
case r of
- Left e -> liftIO $ print e
+ Left e -> liftIO $ warningIO $ show e
Right Nothing -> noop
Right (Just change) -> do
-- Just in case the commit thread is not
diff --git a/Remote/Directory.hs b/Remote/Directory.hs
index c30c3c263..6b6a4b1ce 100644
--- a/Remote/Directory.hs
+++ b/Remote/Directory.hs
@@ -114,10 +114,10 @@ prepareStore d chunkconfig k = ifM (checkDiskSpace (Just d) k 0)
store :: FilePath -> ChunkConfig -> Storer
store d chunkconfig k b p = do
- void $ liftIO $ tryIO $ createDirectoryIfMissing True tmpdir
+ void $ tryIO $ createDirectoryIfMissing True tmpdir
case chunkconfig of
LegacyChunks chunksize -> Legacy.store chunksize finalizer k b p tmpdir destdir
- _ -> flip catchNonAsync (\e -> print e >> return False) $ do
+ _ -> flip catchNonAsync (\e -> warningIO (show e) >> return False) $ do
let tmpf = tmpdir </> keyFile k
meteredWriteFile p tmpf b
finalizer tmpdir destdir
diff --git a/Remote/Helper/Chunked.hs b/Remote/Helper/Chunked.hs
index 5a52a1f4b..5fa6c55ef 100644
--- a/Remote/Helper/Chunked.hs
+++ b/Remote/Helper/Chunked.hs
@@ -77,7 +77,7 @@ numChunks = pred . fromJust . keyChunkNum . fst . nextChunkKeyStream
-}
storeChunks :: UUID -> ChunkConfig -> Key -> FilePath -> MeterUpdate -> (Key -> L.ByteString -> MeterUpdate -> IO Bool) -> Annex Bool
storeChunks u chunkconfig k f p storer = metered (Just p) k $ \meterupdate ->
- either (\e -> liftIO (print e) >> return False) (go meterupdate)
+ either (\e -> warning (show e) >> return False) (go meterupdate)
=<< (liftIO $ tryIO $ L.readFile f)
where
go meterupdate b = case chunkconfig of
@@ -190,7 +190,9 @@ retrieveChunks retriever u chunkconfig encryptor basek basep sink = do
ls <- chunkKeys u chunkconfig basek
liftIO $ flip catchNonAsync giveup (firstavail ls)
where
- giveup e = print e >> return False
+ giveup e = do
+ warningIO (show e)
+ return False
firstavail [] = return False
firstavail ([]:ls) = firstavail ls
diff --git a/Remote/Helper/Chunked/Legacy.hs b/Remote/Helper/Chunked/Legacy.hs
index e435851db..4f402705a 100644
--- a/Remote/Helper/Chunked/Legacy.hs
+++ b/Remote/Helper/Chunked/Legacy.hs
@@ -74,7 +74,7 @@ storeChunks key tmp dest storer recorder finalizer = either onerr return
finalizer tmp dest
return (not $ null stored)
onerr e = do
- print e
+ warningIO (show e)
return False
basef = tmp ++ keyFile key
@@ -105,7 +105,7 @@ storeChunked chunksize dests storer content = either onerr return
| otherwise = storechunks sz [] dests content
onerr e = do
- print e
+ warningIO (show e)
return []
storechunks _ _ [] _ = return [] -- ran out of dests
diff --git a/Remote/WebDAV.hs b/Remote/WebDAV.hs
index 36df60945..31e4225e4 100644
--- a/Remote/WebDAV.hs
+++ b/Remote/WebDAV.hs
@@ -113,7 +113,7 @@ storeHelper :: Remote -> Key -> DavUrl -> DavUser -> DavPass -> L.ByteString ->
storeHelper r k baseurl user pass b = catchBoolIO $ do
mkdirRecursiveDAV tmpurl user pass
case chunkconfig of
- NoChunks -> flip catchNonAsync (\e -> print e >> return False) $ do
+ NoChunks -> flip catchNonAsync (\e -> warningIO (show e) >> return False) $ do
storehttp tmpurl b
finalizer tmpurl keyurl
return True