From e177d917d4c59640f0b2d013dd5e014acb758fe8 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Sat, 20 May 2023 10:37:53 +0300 Subject: [PATCH] warn about exceptions during file decoding --- src/Data/Aeson.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Data/Aeson.hs b/src/Data/Aeson.hs index 6aab0c369..22f0094c8 100644 --- a/src/Data/Aeson.hs +++ b/src/Data/Aeson.hs @@ -219,6 +219,8 @@ decodeStrict = decodeStrictWith jsonEOF fromJSON -- -- This function parses immediately, but defers conversion. See -- 'json' for details. +-- +-- Throws an 'Exception' when the file is missing. decodeFileStrict :: (FromJSON a) => FilePath -> IO (Maybe a) decodeFileStrict = fmap decodeStrict . B.readFile @@ -257,6 +259,8 @@ decodeStrict' = decodeStrictWith jsonEOF' fromJSON -- -- This function parses and performs conversion immediately. See -- 'json'' for details. +-- +-- Throws an 'Exception' when the file is missing. decodeFileStrict' :: (FromJSON a) => FilePath -> IO (Maybe a) decodeFileStrict' = fmap decodeStrict' . B.readFile @@ -276,6 +280,8 @@ eitherDecodeStrict = {-# INLINE eitherDecodeStrict #-} -- | Like 'decodeFileStrict' but returns an error message when decoding fails. +-- +-- Throws an 'Exception' when the file is missing. eitherDecodeFileStrict :: (FromJSON a) => FilePath -> IO (Either String a) eitherDecodeFileStrict = fmap eitherDecodeStrict . B.readFile @@ -293,6 +299,8 @@ eitherDecodeStrict' = {-# INLINE eitherDecodeStrict' #-} -- | Like 'decodeFileStrict'' but returns an error message when decoding fails. +-- +-- Throws an 'Exception' when the file is missing. eitherDecodeFileStrict' :: (FromJSON a) => FilePath -> IO (Either String a) eitherDecodeFileStrict' = fmap eitherDecodeStrict' . B.readFile