Skip to content

Commit 499c299

Browse files
authored
Make sure to actually wrap the action in 'wrapMonadClientSem' (#1786)
* Make sure to actually wrap the action in 'wrapMonadClientSem' * Implement wrapMonadClient in terms of wrapMonadClientSem
1 parent 5ff5cb7 commit 499c299

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

changelog.d/5-internal/raw-effect-row

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Add polysemy to spar; promote the SAMLUser CRUD interface to an effect (#1781)
1+
Add polysemy to spar; promote the SAMLUser CRUD interface to an effect (#1781, #1786)

services/spar/src/Spar/App.hs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,18 @@ instance Member (Final IO) r => Catch.MonadCatch (Sem r) where
213213
-- | Call a cassandra command in the 'Spar' monad. Catch all exceptions and re-throw them as 500 in
214214
-- Handler.
215215
wrapMonadClient :: Cas.Client a -> Spar r a
216-
wrapMonadClient action = do
216+
wrapMonadClient action =
217217
Spar $ do
218218
ctx <- asks sparCtxCas
219-
lift (lift $ embedFinal @IO $ runClient ctx action)
220-
`Catch.catch` (throwSpar . SparCassandraError . cs . show @SomeException)
219+
fromSpar $ wrapMonadClientSem $ embedFinal @IO $ runClient ctx action
221220

221+
-- | Call a 'Sem' command in the 'Spar' monad. Catch all (IO) exceptions and
222+
-- re-throw them as 500 in Handler.
222223
wrapMonadClientSem :: Sem r a -> Spar r a
223-
wrapMonadClientSem action = liftSem $ action
224+
wrapMonadClientSem action =
225+
Spar $
226+
(lift $ lift action)
227+
`Catch.catch` (throwSpar . SparCassandraError . cs . show @SomeException)
224228

225229
insertUser :: Member SAMLUser r => SAML.UserRef -> UserId -> Spar r ()
226230
insertUser uref uid = wrapMonadClientSem $ SAMLUser.insert uref uid

0 commit comments

Comments
 (0)