move tryError to Simplex.Messaging.Util (#191)

This commit is contained in:
Evgeny Poberezkin
2021-09-04 19:01:54 +01:00
committed by GitHub
parent 2ac903a2dd
commit e07bedac0e
2 changed files with 4 additions and 2 deletions

View File

@@ -83,7 +83,7 @@ import qualified Simplex.Messaging.Crypto as C
import Simplex.Messaging.Protocol (MsgBody, SenderPublicKey)
import qualified Simplex.Messaging.Protocol as SMP
import Simplex.Messaging.Transport (ATransport (..), TProxy, Transport (..), runTransportServer)
import Simplex.Messaging.Util (bshow)
import Simplex.Messaging.Util (bshow, tryError)
import System.Random (randomR)
import UnliftIO.Async (Async, async, race_)
import qualified UnliftIO.Exception as E
@@ -427,7 +427,6 @@ runSrvMsgDelivery c@AgentClient {subQ} srv = do
notify connId $ SENT mId
withStore $ \st -> updateSndMsgStatus st connId msgId SndMsgSent
where
tryError action = (Right <$> action) `catchError` (pure . Left)
notify :: ConnId -> ACommand 'Agent -> m ()
notify connId cmd = atomically $ writeTBQueue subQ ("", connId, cmd)

View File

@@ -50,3 +50,6 @@ liftError f = liftEitherError f . runExceptT
liftEitherError :: (MonadIO m, MonadError e' m) => (e -> e') -> IO (Either e a) -> m a
liftEitherError f a = liftIOEither (first f <$> a)
tryError :: MonadError e m => m a -> m (Either e a)
tryError action = (Right <$> action) `catchError` (pure . Left)