From c88e8c82490bddadeb79bddc4a5d46bf4adceb20 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 3 Oct 2018 11:56:52 -0400 Subject: [PATCH] unify error display --- Utility/Url.hs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Utility/Url.hs b/Utility/Url.hs index 3fd02fd432..bf1b74f844 100644 --- a/Utility/Url.hs +++ b/Utility/Url.hs @@ -296,7 +296,7 @@ headRequest r = r download :: MeterUpdate -> URLString -> FilePath -> UrlOptions -> IO Bool download meterupdate url file uo = catchJust matchHttpException go showhttpexception - `catchNonAsync` showerr + `catchNonAsync` (dlfailed . show) where go = case parseURIRelaxed url of Just u -> checkPolicy uo u False $ @@ -313,8 +313,7 @@ download meterupdate url file uo = | otherwise -> downloadcurl Nothing -> do liftIO $ debugM "url" url - hPutStrLn stderr "download failed: invalid url" - return False + dlfailed "invalid url" isfileurl u = uriScheme u == "file:" @@ -383,13 +382,11 @@ download meterupdate url file uo = B8.toString (statusMessage status) _ -> show he #endif + dlfailed msg + dlfailed msg = do hPutStrLn stderr $ "download failed: " ++ msg hFlush stderr return False - showerr e = do - hPutStrLn stderr (show e) - hFlush stderr - return False store initialp mode resp = do sinkResponseFile meterupdate initialp file mode resp