diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs index 258b6bbe7d609635f6c78efbaf3b49c8a1ba41a0..73464a82c13dfd9d0de4ab93ad69994fd81b75de 100644 --- a/lib/CheckMap.hs +++ b/lib/CheckMap.hs @@ -108,8 +108,7 @@ shrinkMapResult !res = res { mapresultAdjusted = () } loadAndLintMap :: LintConfig' -> FilePath -> Int -> IO (Maybe (MapResult Full)) loadAndLintMap config path depth = loadTiledmap path <&> \case Left err -> Just (MapResult mempty mempty mempty mempty Nothing mempty mempty mempty - [ Hint Fatal . toText $ - path <> ": Fatal: " <> err + [ Hint Fatal . toText $ "Fatal: " <> err ]) Right waMap -> Just (runLinter (takeFileName path == "main.json") config waMap depth) diff --git a/tiled/Data/Tiled.hs b/tiled/Data/Tiled.hs index d3ccb2682cf7c7e4d114aa958a5bed919649b8d6..3e6c7372b8022b805fb5c5dc5bfc4cbc9c989704 100644 --- a/tiled/Data/Tiled.hs +++ b/tiled/Data/Tiled.hs @@ -24,6 +24,7 @@ import Data.Aeson hiding (Object) import qualified Data.Aeson as A import Data.Aeson.Types (typeMismatch) import Data.Char (toLower) +import Control.Exception (IOException) -- | options for Aeson's generic encoding and parsing functions @@ -382,6 +383,8 @@ instance ToJSON Tiledmap where -- | Load a Tiled map from the given 'FilePath'. loadTiledmap :: FilePath -> IO (Either String Tiledmap) -loadTiledmap path = eitherDecodeFileStrict' path >>= \case - Left err -> pure $ Left err - Right !tiledmap -> evaluateNF tiledmap <&> Right +loadTiledmap path = catch + (eitherDecodeFileStrict' path >>= \case + Left err -> pure $ Left err + Right !tiledmap -> evaluateNF tiledmap <&> Right) + (\(_ :: IOException) -> pure (Left $ "Failed to read this file."))