@@ -376,7 +376,7 @@ convertWithOpts opts = do
376376 then 0
377377 else optTabStop opts)
378378
379− readSources :: (Functor m, MonadIO m) => [FilePath] -> m String
379+ readSources :: [FilePath] -> PandocIO String
380380 readSources srcs = convertTabs . intercalate "\n" <$>
381381 mapM readSource srcs
382382
@@ -751,6 +751,11 @@ fillMedia sourceURL d = walkM handleImage d
751751 "replacing image with description"
752752 -- emit alt text
753753 return $ Span ("",["image"],[]) lab
754+ PandocHttpError u er -> do
755+ report $ CouldNotFetchResource u
756+ (show er ++ "\rReplacing image with description.")
757+ -- emit alt text
758+ return $ Span ("",["image"],[]) lab
754759 _ -> throwError e)
755760 handleImage x = return x
756761
@@ -800,7 +805,7 @@ applyFilters mbDatadir filters args d = do
800805 expandedFilters <- mapM (expandFilterPath mbDatadir) filters
801806 foldrM ($) d $ map (flip externalFilter args) expandedFilters
802807
803−readSource :: MonadIO m => FilePath -> m String
808+readSource :: FilePath -> PandocIO String
804809readSource "-" = liftIO UTF8.getContents
805810readSource src = case parseURI src of
806811 Just u | uriScheme u `elem` ["http:","https:"] ->
@@ -809,8 +814,12 @@ readSource src = case parseURI src of
809814 liftIO $ UTF8.readFile (uriPath u)
810815 _ -> liftIO $ UTF8.readFile src
811816
812−readURI :: MonadIO m => FilePath -> m String
813−readURI src = liftIO $ (UTF8.toString . fst) <$> openURL src
817+readURI :: FilePath -> PandocIO String
818+readURI src = do
819+ res <- liftIO $ openURL src
820+ case res of
821+ Left e -> throwError $ PandocHttpError src e
822+ Right (contents, _) -> return $ UTF8.toString contents
814823
815824readFile' :: MonadIO m => FilePath -> m B.ByteString
816825readFile' "-" = liftIO B.getContents