Error handling with interop streams

Aug 19, 2014 at 11:37 AM
Edited Aug 19, 2014 at 4:52 PM
Hello dear support,
I wonder if error handling works correctly when using the interop streams (interopstream.h).
I try to download a file from server, as in tutorial, but writing data to a std::ostream object. Of course this std::ostream needs to be wrapped as asynchronous, so code looks like:

std::ostream *p_os = new std::ofstream("result.html", ...); // not always an ofstream
concurrency::streams::stdio_ostream<char> os_wrapper(*p_os);
concurrency::streams::streambuf<char> os_streambuf = os_wrapper.streambuf();

However, from my observations, in case writes to stream buffer fail, no error can be detected, and no exception is thrown (example: disk is full)
The only way would be to check that read_to_end() returns a short value (less than content_length header value / if chunked transfer encoding is not used). Even that does not work on 32 bits machines with files sizes greater than 4GB, as size_t overflows.

Does something exist to detect write errors when calling async istream methods like:
read_to_end(streambuf target)
read(streambuf target, size_t)
when target objects are of type basic_stdio_buffer ?
Aug 21, 2014 at 1:04 AM
Write errors should result in some derived typed from std::exception being thrown. If you're not receiving an error, this sounds like a bug. Also, the size_t issue on 32-bit machines is a definite problem.

I'm opening two issues to track these:
If you have a short program that can reproduce the no-throw effects, it would greatly help us if you could post it to the second workitem above.