Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to propagate errors with Lwt streams? #155

Closed
foretspaisibles opened this issue May 26, 2015 · 1 comment
Closed

How to propagate errors with Lwt streams? #155

foretspaisibles opened this issue May 26, 2015 · 1 comment
Labels
Milestone

Comments

@foretspaisibles
Copy link

Consider a stream created of a Lwt_stream.from or Lwt_stream.from_direct. How are exceptions raised by the function creating stream's elements handled? How can the stream consumer arrange to be noticed about them?

I guess or would expect that the exception is conveyed by a failed thread returned by Lwt_stream.get, but the API-documentation does not go into these details.

Consider a stream created with Let_stream.create() how can the producer notify an error to the stream consumer? It seems that there is no provision for this and the creator and consumer must use a separate line to communicate the error – which is not very convenient!

Thanks!

@foretspaisibles foretspaisibles changed the title How to propagate in Lwt streams? How to propagate errors with Lwt streams? May 26, 2015
@aantron aantron modified the milestone: Lwt_stream Jun 29, 2016
@aantron aantron added the docs label Jul 18, 2016
@aantron aantron modified the milestones: Lwt_stream, 2.7.0 Nov 28, 2016
@aantron aantron closed this as completed in e62cda8 Dec 5, 2016
@aantron
Copy link
Collaborator

aantron commented Dec 5, 2016

I guess or would expect that the exception is conveyed by a failed thread returned by Lwt_stream.get, but the API-documentation does not go into these details.

This is correct, though a subsequent get can cause a subsequent call to the function f passed to from/from_direct, and that call to f might not fail.

Consider a stream created with Let_stream.create() how can the producer notify an error to the stream consumer? It seems that there is no provision for this and the creator and consumer must use a separate line to communicate the error – which is not very convenient!

Indeed, a separate channel has to be used.

I've documented and written tests for the current behavior in the attached commit. Fixing the quirk with push-streams, or deciding what is the correct way to deal with exceptions, is left for #250. This issue is linked from there as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants