From 444f8e9569bef7fc0f92923a5acc4970ce9f710f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 12 Aug 2017 12:25:33 -0700 Subject: Improved error report on loading translation file. --- src/Text/Pandoc/Class.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Class.hs') 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 -- cgit v1.2.3