Skip to content
Snippets Groups Projects
Commit 5936089a authored by Jens Nolte's avatar Jens Nolte
Browse files

Fix `catchSink`: redirect exceptions that don't match type

parent 3bcf720a
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,10 @@ throwToExceptionSinkIO :: (Exception e, MonadIO m) => ExceptionSink -> e -> m ()
throwToExceptionSinkIO sink ex = atomically $ throwToExceptionSink sink ex
catchSink :: forall e. Exception e => (e -> STM ()) -> ExceptionSink -> ExceptionSink
catchSink handler parentSink = ExceptionSink $ mapM_ wrappedHandler . fromException
catchSink handler parentSink = ExceptionSink \ex ->
case fromException ex of
Just matchedException -> wrappedHandler matchedException
Nothing -> throwToExceptionSink parentSink ex
where
wrappedHandler :: e -> STM ()
wrappedHandler ex = catchAll (handler ex) (throwToExceptionSink parentSink)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment