@@ -583,8 +583,7 @@ readDefaultDataFile :: FilePath -> IO BS.ByteString
583583readDefaultDataFile fname =
584584#ifdef EMBED_DATA_FILES
585585 case lookup (makeCanonical fname) dataFiles of
586− Nothing -> ioError $ userError
587− $ "Data file `" ++ fname ++ "' does not exist"
586+ Nothing -> err 97 $ "Could not find data file " ++ fname
588587 Just contents -> return contents
589588 where makeCanonical = joinPath . transformPathParts . splitDirectories
590589 transformPathParts = reverse . foldl go []
@@ -592,7 +591,12 @@ readDefaultDataFile fname =
592591 go (_:as) ".." = as
593592 go as x = x : as
594593#else
595− getDataFileName ("data" </> fname) >>= BS.readFile
594+ getDataFileName ("data" </> fname) >>= checkExistence >>= BS.readFile
595+ where checkExistence fn = do
596+ exists <- doesFileExist fn
597+ if exists
598+ then return fn
599+ else err 97 ("Could not find data file " ++ fname)
596600#endif
597601
598602-- | Read file from specified user data directory or, if not found there, from