How to translate an exception thrown from Stream.onClose handler?
timo.kinnunen at gmail.com
Fri Jan 3 01:43:41 PST 2014
Consider a case where a stream is processed in steps from one form into another, possible many times in succession. The pseudo-code view of it might look like this:
Stream<Document> fromLinesToDocuments(Stream<String> lines);
Stream<Path> fromDocumentsToFiles(Stream<String> documents);
Stream<?> fromFilesToDotDotDot(Stream<Path> files);
Suppose one upstream step needs to add an onClose handler to the Stream and that handler throws an unchecked RuntimeException as normal
The consumers downstream don’t know about an arbitrary low-level exception and don’t care that much either. At the same time, the low-level translator step doesn’t know about higher-level processing steps and shouldn’t have to care in the first place.
So how and where should that RuntimeException be translated into something else?
Sent from Windows Mail
More information about the lambda-dev