Skip to content

Commit

Permalink
Print a more friendly message when http_proxy is down.
Browse files Browse the repository at this point in the history
Fixes #1962.
  • Loading branch information
nkaretnikov authored and 23Skidoo committed Jul 25, 2014
1 parent 440fe65 commit 03c134d
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions cabal-install/Distribution/Client/HttpUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import Network.Browser
, setOutHandler, setErrHandler, setProxy, setAuthorityGen, request)
import Network.Stream
( Result, ConnError(..) )
import Control.Exception
( handleJust )
import Control.Monad
( liftM )
( liftM, guard )
import qualified Data.ByteString.Lazy.Char8 as ByteString
import Data.ByteString.Lazy (ByteString)

Expand All @@ -42,6 +44,8 @@ import System.FilePath
( (<.>) )
import System.Directory
( doesFileExist )
import System.IO.Error
( isDoesNotExistError )

data DownloadResult = FileAlreadyInCache | FileDownloaded FilePath deriving (Eq)

Expand Down Expand Up @@ -88,13 +92,16 @@ cabalBrowse :: Verbosity
-> IO a
cabalBrowse verbosity auth act = do
p <- proxy verbosity
browse $ do
setProxy p
setErrHandler (warn verbosity . ("http error: "++))
setOutHandler (debug verbosity)
auth
setAuthorityGen (\_ _ -> return Nothing)
act
handleJust
(guard . isDoesNotExistError)
(const $ die "Cannot connect to uri. Is http_proxy set?") $
browse $ do
setProxy p
setErrHandler (warn verbosity . ("http error: "++))
setOutHandler (debug verbosity)
auth
setAuthorityGen (\_ _ -> return Nothing)
act

downloadURI :: Verbosity
-> URI -- ^ What to download
Expand Down

0 comments on commit 03c134d

Please sign in to comment.