[Haskell-cafe] How to handle exceptions in conduit?

Hiromi ISHII konn.jinro at gmail.com
Mon Nov 5 13:41:15 CET 2012

Hi, there

On 2012/11/01, at 21:23, Michael Snoyman wrote:

> Due to various technical reasons regarding the nature of conduit, you can't currently catch exceptions within the Pipe monad. You have two options:
> * Catch exceptions before `lift`ing.
> * Catch exceptions thrown from the entire Pipe.
> Since the exceptions are always originating in the underlying monad, the first choice is certainly possible in theory, though may require reworking the library you're using a bit.

Thanks. In my case, used library is relatively small so I can rewrite it to ignore exception before lifting.
But I think it is more convenient doing the same thing without modifying existing code.

The second choice does not match my case because it cannot resume the process from the place just after an exception occurred.

> One other possibility that I haven't actually tried would be to use transPipe[1] to catch all of the exceptions, though I'm not sure how well that would work in practice.

The type of the first argument of `transPipe` should be general, so I think we can't compose it with `catch` function.

-- Hiromi ISHII
konn.jinro at gmail.com

More information about the Haskell-Cafe mailing list