unify error display
This commit is contained in:
parent
2797bf851a
commit
c88e8c8249
1 changed files with 4 additions and 7 deletions
|
@ -296,7 +296,7 @@ headRequest r = r
|
||||||
download :: MeterUpdate -> URLString -> FilePath -> UrlOptions -> IO Bool
|
download :: MeterUpdate -> URLString -> FilePath -> UrlOptions -> IO Bool
|
||||||
download meterupdate url file uo =
|
download meterupdate url file uo =
|
||||||
catchJust matchHttpException go showhttpexception
|
catchJust matchHttpException go showhttpexception
|
||||||
`catchNonAsync` showerr
|
`catchNonAsync` (dlfailed . show)
|
||||||
where
|
where
|
||||||
go = case parseURIRelaxed url of
|
go = case parseURIRelaxed url of
|
||||||
Just u -> checkPolicy uo u False $
|
Just u -> checkPolicy uo u False $
|
||||||
|
@ -313,8 +313,7 @@ download meterupdate url file uo =
|
||||||
| otherwise -> downloadcurl
|
| otherwise -> downloadcurl
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
liftIO $ debugM "url" url
|
liftIO $ debugM "url" url
|
||||||
hPutStrLn stderr "download failed: invalid url"
|
dlfailed "invalid url"
|
||||||
return False
|
|
||||||
|
|
||||||
isfileurl u = uriScheme u == "file:"
|
isfileurl u = uriScheme u == "file:"
|
||||||
|
|
||||||
|
@ -383,13 +382,11 @@ download meterupdate url file uo =
|
||||||
B8.toString (statusMessage status)
|
B8.toString (statusMessage status)
|
||||||
_ -> show he
|
_ -> show he
|
||||||
#endif
|
#endif
|
||||||
|
dlfailed msg
|
||||||
|
dlfailed msg = do
|
||||||
hPutStrLn stderr $ "download failed: " ++ msg
|
hPutStrLn stderr $ "download failed: " ++ msg
|
||||||
hFlush stderr
|
hFlush stderr
|
||||||
return False
|
return False
|
||||||
showerr e = do
|
|
||||||
hPutStrLn stderr (show e)
|
|
||||||
hFlush stderr
|
|
||||||
return False
|
|
||||||
|
|
||||||
store initialp mode resp = do
|
store initialp mode resp = do
|
||||||
sinkResponseFile meterupdate initialp file mode resp
|
sinkResponseFile meterupdate initialp file mode resp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue