dashbitco / nimble_csv

A simple and fast CSV parsing and dumping library for Elixir
https://hexdocs.pm/nimble_csv
772 stars 51 forks source link

Functions throwing exceptions in Stream #7

Closed asconix-old closed 7 years ago

asconix-old commented 8 years ago

I have an issue, that is i guess coming from streams. The lib uses streams, so in the end when I start the stream by ... |> Stream.run I get an exception about e.g. wrong escaped chars etc.

What i want to do is to skip these lines. BUT: the error is triggered by Stream.run, so I loose actually the context to the Stream.map loop. I guess streams spawn processes under the hood, so how to deal with functions throwing exceptions in a stream?

Sample code: https://gist.github.com/asconix/27a032d255b47db4a4ee55d7aa1be0e0

josevalim commented 7 years ago

The stream does not spawn a new process, so you should be able to rescue the whole block but not each individual line.