File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
cli/src/Core/Types/Mnemonics Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ module Core.Types.Mnemonics.Options
4
4
, walletFileOption
5
5
) where
6
6
7
+ import Control.Exception (try )
7
8
import Core.Encryption (decryptText )
8
9
import Core.Types.Mnemonics (Mnemonics (.. ), MnemonicsPhase (.. ))
9
10
import Data.Aeson
@@ -92,11 +93,15 @@ coreMnemonicsParser =
92
93
id
93
94
(decryptText <$> walletPassphraseCommon <*> mnemonicsEncryptedOption)
94
95
96
+ readJSONFile :: FilePath -> IO (Either String Object )
97
+ readJSONFile fp = do
98
+ econtent <- try $ BL. readFile fp
99
+ case econtent of
100
+ Left (e :: IOError ) -> return $ Left $ show e
101
+ Right content -> return $ Aeson. eitherDecode content
102
+
95
103
mnemonicsObject :: Parser Object
96
- mnemonicsObject =
97
- checkMapIO
98
- (fmap Aeson. eitherDecode . BL. readFile )
99
- walletFileOption
104
+ mnemonicsObject = checkMapIO readJSONFile walletFileOption
100
105
101
106
mnemonicsParser :: Parser (Mnemonics 'DecryptedS)
102
107
mnemonicsParser = withConfig (Just <$> mnemonicsObject) coreMnemonicsParser
You can’t perform that action at this time.
0 commit comments