File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 11# Revision history for fs-sim
22
3+ ## ?.?.?.? -- ????-??-??
4+
5+ ### Breaking
6+
7+ * Fix a bug where ` withErrors ` would not put back the previous ` Errors ` when an
8+ exception is thrown during execution of the function. Though we fixed the bug,
9+ it is also a breaking change: the type signature now has an additional
10+ constraint.
11+
312## 0.3.1.0 -- 2024-12-10
413
514### Non-breaking
Original file line number Diff line number Diff line change @@ -572,15 +572,12 @@ runSimErrorFS mockFS errors action = do
572572
573573-- | Execute the next action using the given 'Errors'. After the action is
574574-- finished, the previous 'Errors' are restored.
575- withErrors :: MonadSTM m => StrictTVar m Errors -> Errors -> m a -> m a
576- withErrors errorsVar tempErrors action = do
577- originalErrors <- atomically $ do
578- originalErrors <- readTVar errorsVar
579- writeTVar errorsVar tempErrors
580- return originalErrors
581- res <- action
582- atomically $ writeTVar errorsVar originalErrors
583- return res
575+ withErrors :: (MonadSTM m , MonadThrow m ) => StrictTVar m Errors -> Errors -> m a -> m a
576+ withErrors errorsVar tempErrors action =
577+ bracket
578+ (atomically $ swapTVar errorsVar tempErrors)
579+ (\ originalErrors -> atomically $ swapTVar errorsVar originalErrors)
580+ $ \ _ -> action
584581
585582{- ------------------------------------------------------------------------------
586583 Utilities
You can’t perform that action at this time.
0 commit comments