I've created a simple rx operator that converts a stream of strings to a stream of jsons and it works fine. However, I would like to be able to raise a custom exception and I am not sure how to call the on_error
method of the subscription
The operator is called convertStringToJson
and a working sample can be found here: https://github.com/cipriancaba/rxcpp-examples/blob/master/src/SimpleOperators.cpp
function<observable<json>(observable<string>)> SimpleOperators::convertFromStringToJson() {
return [](observable<string> $str) {
return $str |
Rx::map([](const string s) {
return json::parse(s);
});
};
}
rxcpp will work if you use try/catch to translate the exception.
However, the intended pattern is to use on_error_resume_next() to translate the exception.
This is the code:
I opened a pull request on github with this code.
https://github.com/cipriancaba/rxcpp-examples/pull/1