urdl icon indicating copy to clipboard operation
urdl copied to clipboard

Question: should I check for read errors after urdl::stream::rdbuf()

Open jamiebullock opened this issue 8 years ago • 0 comments

It's not clear to me how to correctly handle errors when using the following idiom:

std::ofstream os(path, std::ios_base::out | std::ios_base::binary);
            
if (!os)
{
       throw std::runtime_error(...);
}   
            
os << is.rdbuf();
is.close();
os.close();

Should I for example check after os << is.rdbuf() using something like:

if (!is)
{
         throw std::runtime_error(is.error().message());
}

jamiebullock avatar Aug 29 '17 14:08 jamiebullock