aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-08-12 12:25:33 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-08-12 12:25:33 -0700
commit444f8e9569bef7fc0f92923a5acc4970ce9f710f (patch)
treeee82c5f0547fc18a043ca32dbb5d00e52515359d /src
parent622c3f2fa6c29ecc33502f63ae6f33e59c11c96c (diff)
downloadpandoc-444f8e9569bef7fc0f92923a5acc4970ce9f710f.tar.gz
Improved error report on loading translation file.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Class.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs
index 074181c92..25d6d2927 100644
--- a/src/Text/Pandoc/Class.hs
+++ b/src/Text/Pandoc/Class.hs
@@ -346,10 +346,12 @@ getTranslations = do
Just (lang, Nothing) -> do -- read from file
let translationFile = "translations/" ++ renderLang lang ++ ".yaml"
let fallbackFile = "translations/" ++ langLanguage lang ++ ".yaml"
- let getTrans bs =
+ let getTrans fp = do
+ bs <- readDataFile fp
case readTranslations (UTF8.toString bs) of
Left e -> do
- report $ CouldNotLoadTranslations (renderLang lang) e
+ report $ CouldNotLoadTranslations (renderLang lang)
+ (fp ++ ": " ++ e)
-- make sure we don't try again...
modifyCommonState $ \st ->
st{ stTranslations = Nothing }
@@ -358,9 +360,9 @@ getTranslations = do
modifyCommonState $ \st ->
st{ stTranslations = Just (lang, Just t) }
return t
- catchError (readDataFile translationFile >>= getTrans)
+ catchError (getTrans translationFile)
(\_ ->
- catchError (readDataFile fallbackFile >>= getTrans)
+ catchError (getTrans fallbackFile)
(\e -> do
report $ CouldNotLoadTranslations (renderLang lang)
$ case e of