Commit 03c134d5 authored by nkaretnikov's avatar nkaretnikov Committed by Mikhail Glushenkov
Browse files

Print a more friendly message when http_proxy is down.

Fixes #1962.
parent 440fe65e
......@@ -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)
......@@ -42,6 +44,8 @@ import System.FilePath
( (<.>) )
import System.Directory
( doesFileExist )
import System.IO.Error
( isDoesNotExistError )
data DownloadResult = FileAlreadyInCache | FileDownloaded FilePath deriving (Eq)
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment