Skip to content

Commit 546e3bc

Browse files
committed
Fix fetching of protocol paramters if they are not specified in config and if file is not present
Previously we would only fetch the file if JSON.decode returned a Left, however if the file is not present an IOError will be thrown and the code to fetch the file through the CLI was never being executed Change-type: patch Signed-off-by: Giovanni Garufi <giovanni@mlabs.city>
1 parent 33fabb8 commit 546e3bc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/PlutusConfig/Cardano/Api/Shelley.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Config.Schema (
2020
naturalSpec,
2121
sectionsSpec,
2222
)
23+
import Control.Exception (IOException, catch)
2324
import Data.Aeson qualified as JSON
2425
import Data.ByteString.Lazy qualified as LazyByteString
2526
import Data.Default (def)
@@ -276,7 +277,7 @@ instance HasSpec ProtocolParameters where
276277
pure ProtocolParameters {..}
277278

278279
readProtocolParametersJSON :: FilePath -> IO (Either String ProtocolParameters)
279-
readProtocolParametersJSON fn = JSON.eitherDecode <$> LazyByteString.readFile fn
280+
readProtocolParametersJSON fn = (JSON.eitherDecode <$> LazyByteString.readFile fn) `catch` (\(e :: IOException) -> pure $ Left (show e))
280281

281282
writeProtocolParametersJSON :: FilePath -> ProtocolParameters -> IO ()
282283
writeProtocolParametersJSON fn params =

0 commit comments

Comments
 (0)