summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/FB2.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-12-12 13:51:20 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-25 17:07:42 +0100
commit6aff97e4e16b3829151a5e84b63a0aee26ea8511 (patch)
treebdab822f07f9d868ab8714dc8a392f48278b8d6e /src/Text/Pandoc/Writers/FB2.hs
parent4cb124d147790814cf2055afdfd17e500cece559 (diff)
Text.Pandoc.Shared: Removed fetchItem, fetchItem'.
Made changes where these are used, so that the version of fetchItem from PandocMonad can be used instead.
Diffstat (limited to 'src/Text/Pandoc/Writers/FB2.hs')
-rw-r--r--src/Text/Pandoc/Writers/FB2.hs18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs
index 20af67b62..7baac4f9e 100644
--- a/src/Text/Pandoc/Writers/FB2.hs
+++ b/src/Text/Pandoc/Writers/FB2.hs
@@ -39,7 +39,7 @@ import Text.XML.Light
import qualified Text.XML.Light as X
import qualified Text.XML.Light.Cursor as XC
import qualified Data.ByteString.Char8 as B8
-import Control.Monad.Except (throwError)
+import Control.Monad.Except (throwError, catchError)
import Text.Pandoc.Definition
@@ -241,10 +241,18 @@ fetchImage href link = do
else return Nothing
(True, Just _) -> return Nothing -- not base64-encoded
_ -> do
- response <- P.fetchItem Nothing link
- case response of
- Right (bs, Just mime) -> return $ Just (mime, B8.unpack $ encode bs)
- _ -> return $ Nothing
+ catchError (do (bs, mbmime) <- P.fetchItem Nothing link
+ case mbmime of
+ Nothing -> do
+ P.warning ("Could not determine mime type for "
+ ++ link)
+ return Nothing
+ Just mime -> return $ Just (mime,
+ B8.unpack $ encode bs))
+ (\e ->
+ do P.warning ("Could not fetch " ++ link ++
+ ":\n" ++ show e)
+ return Nothing)
case mbimg of
Just (imgtype, imgdata) -> do
return . Right $ el "binary"