Is it possible to get element on which an error during processing happened?
I could throw a custom exception which contains the element at every stage through a recovery mechanism, but I want avoid adding same code to every stage.
I’d like to write that code for whole stream if it possible.
Nothing built in for that, catching the exceptions and doing in-stream modeling of ok messages vs messages you couldn’t process is the way to go.
In general the exception handling in Akka, both streams and actors, is built around the idea that you should separate failures (things you cannot really do much about other than restarting, retrying or giving up, for example transient network problems) from validation errors (problems with the actual data) which it wouldn’t help to retry since the data will still be faulty and the only way to deal wit that is to include protocol or behavior for it (“Hey, you sent me bad data!”, pass it to some bad-data-sink, log it and move on).