Skip to content
Snippets Groups Projects
Commit f2d01e5a authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Merge pull request #2560 from 23Skidoo/issue-1962

Print a more friendly message when http_proxy is down.
parents 2b3a6949 a4d55d69
No related branches found
No related tags found
No related merge requests found
...@@ -21,8 +21,10 @@ import Network.Browser ...@@ -21,8 +21,10 @@ import Network.Browser
, setOutHandler, setErrHandler, setProxy, setAuthorityGen, request) , setOutHandler, setErrHandler, setProxy, setAuthorityGen, request)
import Network.Stream import Network.Stream
( Result, ConnError(..) ) ( Result, ConnError(..) )
import Control.Exception
( handleJust )
import Control.Monad import Control.Monad
( liftM ) ( liftM, guard )
import qualified Data.ByteString.Lazy.Char8 as ByteString import qualified Data.ByteString.Lazy.Char8 as ByteString
import Data.ByteString.Lazy (ByteString) import Data.ByteString.Lazy (ByteString)
...@@ -42,6 +44,8 @@ import System.FilePath ...@@ -42,6 +44,8 @@ import System.FilePath
( (<.>) ) ( (<.>) )
import System.Directory import System.Directory
( doesFileExist ) ( doesFileExist )
import System.IO.Error
( isDoesNotExistError )
data DownloadResult = FileAlreadyInCache | FileDownloaded FilePath deriving (Eq) data DownloadResult = FileAlreadyInCache | FileDownloaded FilePath deriving (Eq)
...@@ -88,13 +92,17 @@ cabalBrowse :: Verbosity ...@@ -88,13 +92,17 @@ cabalBrowse :: Verbosity
-> IO a -> IO a
cabalBrowse verbosity auth act = do cabalBrowse verbosity auth act = do
p <- proxy verbosity p <- proxy verbosity
browse $ do handleJust
setProxy p (guard . isDoesNotExistError)
setErrHandler (warn verbosity . ("http error: "++)) (const . die $ "Couldn't establish HTTP connection. "
setOutHandler (debug verbosity) ++ "Possible cause: HTTP proxy server is down.") $
auth browse $ do
setAuthorityGen (\_ _ -> return Nothing) setProxy p
act setErrHandler (warn verbosity . ("http error: "++))
setOutHandler (debug verbosity)
auth
setAuthorityGen (\_ _ -> return Nothing)
act
downloadURI :: Verbosity downloadURI :: Verbosity
-> URI -- ^ What to download -> URI -- ^ What to download
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment