Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conduit Exception

I couldn't figure out how to make sourceDirectory and catchC work.

src = (sourceDirectory "/does/not/exist/input.txt" $$ C.print) `catchC` \e ->
    yield (pack $ "Could not read input file: " ++ show (e :: IOException))

The idea is that I use sourceDirectory to walk a directory tree and in case of failure I want the program to continue and not stop.

like image 327
McBear Holden Avatar asked Feb 22 '26 04:02

McBear Holden


1 Answers

The catchC function works on individual components of a pipeline, like sourceDirectory "somedir" (in other words, things of type ConduitM). You've applied it to a completely run pipeline, which is just a normal action, and therefore catchC won't work. Your choices are:

  • Apply catchC to the individual component, e.g. (sourceDirectory "foo" `catchC` handler) $$ printC
  • Use a non-conduit-specific catch function (such as from safe-exceptions), e.g. (sourceDirectory "foo" $$ printC) `catch` handler.

Also, a recommendation for the future: it's a good idea to include the compiler error when some code won't build.

like image 183
Michael Snoyman Avatar answered Feb 24 '26 20:02

Michael Snoyman