Improve error handling

This commit is contained in:
2020-03-17 18:40:25 +01:00
parent 9c7d17800d
commit 35b6359c1b
2 changed files with 29 additions and 17 deletions

View File

@@ -43,7 +43,7 @@ import Data.Time.Format
import Data.Versions
import GHC.IO.Exception
import HPath
import HPath.IO
import HPath.IO as HIO
import Haskus.Utils.Variant.Excepts
import Network.Http.Client hiding ( URL )
import OpenSSL.Digest
@@ -137,7 +137,11 @@ getDownloads urlSource = do
let path = view pathL' uri'
json_file <- (liftIO $ ghcupCacheDir)
>>= \cacheDir -> (cacheDir </>) <$> urlBaseName path
e <- liftIO $ doesFileExist json_file
e <-
liftIO
$ HIO.handleIOError
(\e -> if isDoesNotExistError e then pure False else throwIO e)
$ doesFileExist json_file
if e
then do
accessTime <-