From db2bd423a00e582dd966d040df70d6994122b7ff Mon Sep 17 00:00:00 2001 From: stuebinm Date: Fri, 8 Apr 2022 14:12:00 +0200 Subject: linter: don't fail on missing maps turns out eitherDecodeFile' doesn't have the semantics I thought it did (who writes functions returning either that can still fail??) --- tiled/Data/Tiled.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tiled/Data') diff --git a/tiled/Data/Tiled.hs b/tiled/Data/Tiled.hs index d3ccb26..3e6c737 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.")) -- cgit v1.2.3