parsonsmatt commented on this pull request.
+— | Reads user public from file, assuming that file exists,
+— and has mode 600, throws exception in other case
+readUserPublic :: (MonadIO m, WithLogger m) => FilePath -> m UserPublic
+readUserPublic :: (MonadIO m) => FilePath -> m UserPublic
+readUserPublic path = do
+ ensureModeIs600 path
+ 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.