Commit 2be7915e authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

update EXPECT_THROW_ERRNO() to match std::generic_category

Summary:
std::system_error exceptions generated from an errno value should use
`std::generic_category`.  Previously EXPECT_THROW_ERRNO() only handled
exceptions using `std::system_category` since `folly/Exception.h` (incorrectly)
throws exceptions using `std::system_category`

This updates EXPECT_THROW_ERRNO() to accept either std::generic_category or
std::system_category.

In the future we can drop the check for std::system_category here once we fix
folly/Exception.h to throw exceptions using std::generic_category.

Reviewed By: yfeldblum

Differential Revision: D7329998

fbshipit-source-id: 89295d7c8276c9119c29325bf35c0bf27452b779
parent c85bb59d
......@@ -182,10 +182,13 @@ CheckResult checkThrowErrno(Fn&& fn, int errnoValue, const char* statementStr) {
try {
fn();
} catch (const std::system_error& ex) {
// TODO: POSIX errno values should really use std::generic_category(),
// but folly/Exception.h throws them with std::system_category() at the
// moment.
if (ex.code().category() != std::system_category()) {
// TODO: POSIX errno values should use std::generic_category(), but
// folly/Exception.h incorrectly throws them using std::system_category()
// at the moment.
// For now we also accept std::system_category so that we will also handle
// exceptions from folly/Exception.h correctly.
if (ex.code().category() != std::generic_category() &&
ex.code().category() != std::system_category()) {
return CheckResult(false)
<< "Expected: " << statementStr << " throws an exception with errno "
<< errnoValue << " (" << std::generic_category().message(errnoValue)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment