Skip to content

Commit

Permalink
Improved error message when DeleteDataSubscription fails because the …
Browse files Browse the repository at this point in the history
…DataSubscription doesn't exists
  • Loading branch information
mpscholten committed Jul 19, 2022
1 parent 9fcb428 commit d67fb1f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions IHP/DataSync/ControllerImpl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,15 @@ runDataSyncController ensureRLSEnabled installTableChangeTriggers receiveData se
handleMessage DeleteDataSubscription { requestId, subscriptionId } = do
DataSyncReady { subscriptions } <- getState
let (Just closeSignalMVar) = HashMap.lookup subscriptionId subscriptions
-- Cancel table watcher
MVar.putMVar closeSignalMVar ()
case HashMap.lookup subscriptionId subscriptions of
Just closeSignalMVar -> do
-- Cancel table watcher
MVar.putMVar closeSignalMVar ()
modifyIORef' ?state (\state -> state |> modify #subscriptions (HashMap.delete subscriptionId))
modifyIORef' ?state (\state -> state |> modify #subscriptions (HashMap.delete subscriptionId))
sendJSON DidDeleteDataSubscription { subscriptionId, requestId }
sendJSON DidDeleteDataSubscription { subscriptionId, requestId }
Nothing -> error ("Failed to delete DataSubscription, could not find DataSubscription with id " <> tshow subscriptionId)
handleMessage CreateRecordMessage { table, record, requestId, transactionId } = do
ensureRLSEnabled table
Expand Down

0 comments on commit d67fb1f

Please sign in to comment.