Skip to content

Commit d7228f4

Browse files
committed
Add a workaround for Microsoft's non-conformant std::system_error.
1 parent 383b05e commit d7228f4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

asio/boostify.pl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,13 @@ sub copy_source_file
310310
last if $line =~ /boostify: non-boost docs end here/;
311311
}
312312
}
313+
elsif ($line =~ /boostify: non-boost code starts here/)
314+
{
315+
while ($line = <$input>)
316+
{
317+
last if $line =~ /boostify: non-boost code ends here/;
318+
}
319+
}
313320
elsif ($line =~ /^$/ && $needs_doc_link)
314321
{
315322
$needs_doc_link = 0;

asio/include/asio/detail/impl/throw_error.ipp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,23 @@ void do_throw_error(const asio::error_code& err)
3333

3434
void do_throw_error(const asio::error_code& err, const char* location)
3535
{
36+
// boostify: non-boost code starts here
37+
#if defined(ASIO_MSVC) && defined(ASIO_HAS_STD_SYSTEM_ERROR)
38+
// Microsoft's implementation of std::system_error is non-conformant in that
39+
// it ignores the error code's message when a "what" string is supplied. We'll
40+
// work around this by explicitly formatting the "what" string.
41+
std::string what_msg = location;
42+
what_msg += ": ";
43+
what_msg += err.message();
44+
asio::system_error e(err, what_msg);
45+
asio::detail::throw_exception(e);
46+
#else // defined(ASIO_MSVC) && defined(ASIO_HAS_STD_SYSTEM_ERROR)
47+
// boostify: non-boost code ends here
3648
asio::system_error e(err, location);
3749
asio::detail::throw_exception(e);
50+
// boostify: non-boost code starts here
51+
#endif // defined(ASIO_MSVC) && defined(ASIO_HAS_STD_SYSTEM_ERROR)
52+
// boostify: non-boost code ends here
3853
}
3954

4055
} // namespace detail

0 commit comments

Comments
 (0)