[input-output-hk/cardano-sl] [CHW-71][CHW-57][CHW-68][CHW-80][CHW-106] [CHW-54] Basic HD Wallet functionalities (Create/spend/receive) (#3103)

parsonsmatt commented on this pull request.

> +
+— | Reads user public from file, assuming that file exists,
+— and has mode 600, throws exception in other case
+#ifdef POSIX
+readUserPublic :: (MonadIO m, WithLogger m) => FilePath -> m UserPublic
+#else
+readUserPublic :: (MonadIO m) => FilePath -> m UserPublic
+#endif
+readUserPublic path = do
+#ifdef POSIX
+ ensureModeIs600 path
+#endif
+ takeReadLock path $ do
+ content <- either (throwM . UserPublicDecodingError . toText) pure . + decodeFull' =<< BS.readFile path + pure $ content & upPath .~ path I like @erikd's suggestion. I would change the error handling logic to check the `IOError` was actually a FileNotFound or whatever it throws in that case, and only rewrap the necessary information.

Добавить комментарий