chriskohlhoff / urdl

Urdl C++ Library - Urdl is a cross-platform C++ library for downloading web content using a URL. It provides an easy-to-use extension to standard C++ iostreams and an asynchronous interface for use with Boost.Asio.

Home Page:http://think-async.com/Urdl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jamiebullock opened this issue · 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());
}