Skip to content

Commit d7d8cc2

Browse files
committed
Retrying with MonadMask
1 parent 60cd442 commit d7d8cc2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

log-base/src/Log/Monad.hs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,27 @@ runLogT component logger maxLogLevel m = runReaderT (unLogT m) LoggerEnv {
7575
-- doesn't guarantee that all messages are actually written to the log
7676
-- once it finishes. Use 'withPGLogger' or 'withElasticSearchLogger'
7777
-- for that.
78-
runLogTAttentionOnFailure :: (MonadCatch m, MonadBase IO m)
78+
runLogTAttentionOnFailure :: (MonadBase IO m, MonadMask m)
7979
=> Text -- ^ Application component name to use.
8080
-> Logger -- ^ The logging back-end to use.
8181
-> LogLevel -- ^ The maximum log level allowed to be logged.
8282
-- Only messages less or equal than this level with be logged.
8383
-> LogT m a -- ^ The 'LogT' computation to run.
8484
-> m a
8585
runLogTAttentionOnFailure component logger maxLogLevel m =
86-
runReaderT
87-
(unLogT $ do
88-
m `catch`
89-
(\(SomeException e) -> do
86+
fst <$> runReaderT
87+
(unLogT $
88+
generalBracket
89+
(pure ())
90+
(\_ -> \case
91+
ExitCaseSuccess _ -> pure ()
92+
ExitCaseException (SomeException e) -> do
9093
logAttention "Uncaught exception raised" $ object ["error" .= show e]
91-
error "In a catch"))
94+
error "In a catch"
95+
ExitCaseAbort ->
96+
logAttention_ "Process was aborted"
97+
)
98+
(const m))
9299
LoggerEnv
93100
{ leLogger = logger
94101
, leComponent = component

0 commit comments

Comments
 (0)