remote: getError -> getErrors

This commit is contained in:
Richard Marko 2023-11-26 14:34:27 +01:00 committed by sorki
parent 76a8632d9c
commit 14b739aaed
2 changed files with 7 additions and 10 deletions

View File

@ -6,7 +6,7 @@ module System.Nix.Store.Remote.MonadStore
, getLog
, flushLog
, gotError
, getError
, getErrors
, setData
, clearData
) where
@ -43,8 +43,8 @@ mapStoreDir f = mapExceptT . mapStateT . withReaderT
gotError :: MonadStore Bool
gotError = gets (any isError . snd)
getError :: MonadStore [Logger]
getError = gets (filter isError . snd)
getErrors :: MonadStore [Logger]
getErrors = gets (filter isError . snd)
getLog :: MonadStore [Logger]
getLog = gets snd

View File

@ -26,7 +26,6 @@ import qualified Data.Bool
import Data.Serialize.Get
import Data.Serialize.Put
import qualified Data.ByteString
import qualified Data.ByteString.Char8
import Network.Socket (SockAddr(SockAddrUnix))
import qualified Network.Socket as S
@ -68,9 +67,8 @@ simpleOpArgs op args = do
Data.Bool.bool
sockGetBool
(do
-- TODO: errorExitStatus, head
Logger_Error{..} <- head <$> getError
throwError $ Data.ByteString.Char8.unpack errorMessage
-- TODO: don't use show
getErrors >>= throwError . show
)
err
@ -98,9 +96,8 @@ runOpArgsIO op encoder = do
modify (\(a, b) -> (a, b <> out))
err <- gotError
Control.Monad.when err $ do
-- TODO: errorExitStatus, head
Logger_Error{..} <- head <$> getError
throwError $ Data.ByteString.Char8.unpack errorMessage
-- TODO: don't use show
getErrors >>= throwError . show
runStore :: MonadStore a -> IO (Either String a, [Logger])
runStore = runStoreOpts defaultSockPath def