Clear error codes idiomatically

This commit is contained in:
Vinnie Falco committed 2019-01-20 09:50:43 -08:00
1 parent 9ea70bfbe5
commit 944b5dcda7
29 files changed
+118 -112

No files matched your search

+1 -1
View File
@@ -154,7 +154,7 @@ detect_ssl(
{
// This is a fast way to indicate success
// without retrieving the default category.
ec.assign(0, ec.category());
ec = {};
return result;
}
+2 -2
View File
@@ -1094,7 +1094,7 @@ read_and_print_body(
p.get().body().size = sizeof(buf);
read(stream, buffer, p, ec);
if(ec == error::need_buffer)
ec.assign(0, ec.category());
ec = {};
if(ec)
return;
os.write(buf, sizeof(buf) - p.get().body().size);
@@ -1201,7 +1201,7 @@ print_chunked_body(
else if(ec != error::end_of_chunk)
return;
else
ec.assign(0, ec.category());
ec = {};
// We got a whole chunk, print the extensions:
for(auto const& extension : ce)
@@ -191,7 +191,7 @@ public:
{
// Rationale:
// http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error
ec.assign(0, ec.category());
ec = {};
}
if(ec)
return fail(ec, "shutdown");
@@ -113,7 +113,7 @@ do_session(
{
// Rationale:
// http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error
ec.assign(0, ec.category());
ec = {};
}
if(ec)
return fail(ec, "shutdown");
@@ -111,7 +111,7 @@ int main(int argc, char** argv)
{
// Rationale:
// http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error
ec.assign(0, ec.category());
ec = {};
}
if(ec)
throw beast::system_error{ec};