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 1
1
# Revision history for fs-sim
2
2
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
+
3
12
## 0.3.1.0 -- 2024-12-10
4
13
5
14
### Non-breaking
Original file line number Diff line number Diff line change @@ -572,15 +572,12 @@ runSimErrorFS mockFS errors action = do
572
572
573
573
-- | Execute the next action using the given 'Errors'. After the action is
574
574
-- 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
584
581
585
582
{- ------------------------------------------------------------------------------
586
583
Utilities
You can’t perform that action at this time.
0 commit comments