Commit 811bad8a authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Don't declare a variable for exceptions we discard

Summary: They aren't needed and they count as initialized but unused variables.

Reviewed By: yfeldblum

Differential Revision: D4308844

fbshipit-source-id: a6833dbf434ebdefff0b375729a4e62495463ac0
parent b4a27a03
...@@ -256,7 +256,7 @@ void BaseFormatter<Derived, containerMode, Args...>::operator()(Output& out) ...@@ -256,7 +256,7 @@ void BaseFormatter<Derived, containerMode, Args...>::operator()(Output& out)
try { try {
argIndex = to<int>(piece); argIndex = to<int>(piece);
} catch (const std::out_of_range& e) { } catch (const std::out_of_range&) {
arg.error("argument index must be integer"); arg.error("argument index must be integer");
} }
arg.enforce(argIndex >= 0, "argument index must be non-negative"); arg.enforce(argIndex >= 0, "argument index must be non-negative");
......
...@@ -267,7 +267,7 @@ inline int FormatArg::splitIntKey() { ...@@ -267,7 +267,7 @@ inline int FormatArg::splitIntKey() {
} }
try { try {
return to<int>(doSplitKey<true>()); return to<int>(doSplitKey<true>());
} catch (const std::out_of_range& e) { } catch (const std::out_of_range&) {
error("integer key required"); error("integer key required");
return 0; // unreached return 0; // unreached
} }
......
...@@ -263,11 +263,11 @@ template <typename Fn> ...@@ -263,11 +263,11 @@ template <typename Fn>
void DynamicParser::wrapError(const folly::dynamic* lookup_k, Fn fn) { void DynamicParser::wrapError(const folly::dynamic* lookup_k, Fn fn) {
try { try {
fn(); fn();
} catch (DynamicParserLogicError& ex) { } catch (DynamicParserLogicError&) {
// When the parser is misused, we throw all the way up to the user, // When the parser is misused, we throw all the way up to the user,
// instead of reporting it as if the input is invalid. // instead of reporting it as if the input is invalid.
throw; throw;
} catch (DynamicParserParseError& ex) { } catch (DynamicParserParseError&) {
// We are just bubbling up a parse error for OnError::THROW. // We are just bubbling up a parse error for OnError::THROW.
throw; throw;
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
......
...@@ -691,7 +691,7 @@ void SchemaValidator::loadSchema(SchemaValidatorContext& context, ...@@ -691,7 +691,7 @@ void SchemaValidator::loadSchema(SchemaValidatorContext& context,
s = s->get_ptr(pos); s = s->get_ptr(pos);
continue; continue;
} }
} catch (const std::range_error& e) { } catch (const std::range_error&) {
// ignore // ignore
} }
} }
......
...@@ -119,7 +119,7 @@ void GFlagValueSemanticBase<T>::parse(boost::any& valueStore, ...@@ -119,7 +119,7 @@ void GFlagValueSemanticBase<T>::parse(boost::any& valueStore,
try { try {
val = this->parseValue(tokens); val = this->parseValue(tokens);
this->transform(val); this->transform(val);
} catch (const std::exception& e) { } catch (const std::exception&) {
throw po::invalid_option_value( throw po::invalid_option_value(
tokens.empty() ? std::string() : tokens.front()); tokens.empty() ? std::string() : tokens.front());
} }
......
...@@ -1710,7 +1710,7 @@ void AsyncSSLSocket::clientHelloParsingCallback(int written, ...@@ -1710,7 +1710,7 @@ void AsyncSSLSocket::clientHelloParsingCallback(int written,
} }
} }
} }
} catch (std::out_of_range& e) { } catch (std::out_of_range&) {
// we'll use what we found and cleanup below. // we'll use what we found and cleanup below.
VLOG(4) << "AsyncSSLSocket::clientHelloParsingCallback(): " VLOG(4) << "AsyncSSLSocket::clientHelloParsingCallback(): "
<< "buffer finished unexpectedly." << " AsyncSSLSocket socket=" << sock; << "buffer finished unexpectedly." << " AsyncSSLSocket socket=" << sock;
......
...@@ -449,7 +449,7 @@ void AsyncServerSocket::bind(uint16_t port) { ...@@ -449,7 +449,7 @@ void AsyncServerSocket::bind(uint16_t port) {
setupAddress(res); setupAddress(res);
} }
} }
} catch (const std::system_error& e) { } catch (const std::system_error&) {
// If we can't bind to the same port on ipv4 as ipv6 when using // If we can't bind to the same port on ipv4 as ipv6 when using
// port=0 then we will retry again before giving up after // port=0 then we will retry again before giving up after
// kNumTries attempts. We do this by closing the sockets that // kNumTries attempts. We do this by closing the sockets that
...@@ -953,7 +953,7 @@ void AsyncServerSocket::enterBackoff() { ...@@ -953,7 +953,7 @@ void AsyncServerSocket::enterBackoff() {
if (backoffTimeout_ == nullptr) { if (backoffTimeout_ == nullptr) {
try { try {
backoffTimeout_ = new BackoffTimeout(this); backoffTimeout_ = new BackoffTimeout(this);
} catch (const std::bad_alloc& ex) { } catch (const std::bad_alloc&) {
// Man, we couldn't even allocate the timer to re-enable accepts. // Man, we couldn't even allocate the timer to re-enable accepts.
// We must be in pretty bad shape. Don't pause accepting for now, // We must be in pretty bad shape. Don't pause accepting for now,
// since we won't be able to re-enable ourselves later. // since we won't be able to re-enable ourselves later.
......
...@@ -753,7 +753,7 @@ void NotificationQueue<MessageT>::Consumer::consumeMessages( ...@@ -753,7 +753,7 @@ void NotificationQueue<MessageT>::Consumer::consumeMessages(
if (wasEmpty) { if (wasEmpty) {
return; return;
} }
} catch (const std::exception& ex) { } catch (const std::exception&) {
// This catch block is really just to handle the case where the MessageT // This catch block is really just to handle the case where the MessageT
// constructor throws. The messageAvailable() callback itself is // constructor throws. The messageAvailable() callback itself is
// declared as noexcept and should never throw. // declared as noexcept and should never throw.
......
...@@ -311,7 +311,7 @@ TEST(AsyncSSLSocketTest, HandshakeError) { ...@@ -311,7 +311,7 @@ TEST(AsyncSSLSocketTest, HandshakeError) {
uint8_t readbuf[128]; uint8_t readbuf[128];
uint32_t bytesRead = socket->readAll(readbuf, sizeof(readbuf)); uint32_t bytesRead = socket->readAll(readbuf, sizeof(readbuf));
LOG(ERROR) << "readAll returned " << bytesRead << " instead of throwing"; LOG(ERROR) << "readAll returned " << bytesRead << " instead of throwing";
} catch (AsyncSocketException &e) { } catch (AsyncSocketException&) {
ex = true; ex = true;
} }
EXPECT_TRUE(ex); EXPECT_TRUE(ex);
......
...@@ -275,7 +275,7 @@ void contendedRW(size_t itersPerThread, ...@@ -275,7 +275,7 @@ void contendedRW(size_t itersPerThread,
if (!pr.second) { if (!pr.second) {
pr.first->second.data++; pr.first->second.data++;
} }
} catch (std::bad_alloc& x) { } catch (std::bad_alloc&) {
LOG(INFO) << "bad alloc"; LOG(INFO) << "bad alloc";
} }
} }
......
...@@ -667,7 +667,7 @@ TEST(Conv, DoubleToInt) { ...@@ -667,7 +667,7 @@ TEST(Conv, DoubleToInt) {
auto i2 = to<int>(42.1); auto i2 = to<int>(42.1);
LOG(ERROR) << "to<int> returned " << i2 << " instead of throwing"; LOG(ERROR) << "to<int> returned " << i2 << " instead of throwing";
EXPECT_TRUE(false); EXPECT_TRUE(false);
} catch (std::range_error& e) { } catch (std::range_error&) {
//LOG(INFO) << e.what(); //LOG(INFO) << e.what();
} }
} }
...@@ -684,7 +684,7 @@ TEST(Conv, EnumToInt) { ...@@ -684,7 +684,7 @@ TEST(Conv, EnumToInt) {
<< static_cast<unsigned int>(i2) << static_cast<unsigned int>(i2)
<< " instead of throwing"; << " instead of throwing";
EXPECT_TRUE(false); EXPECT_TRUE(false);
} catch (std::range_error& e) { } catch (std::range_error&) {
//LOG(INFO) << e.what(); //LOG(INFO) << e.what();
} }
} }
...@@ -709,7 +709,7 @@ TEST(Conv, IntToEnum) { ...@@ -709,7 +709,7 @@ TEST(Conv, IntToEnum) {
<< static_cast<unsigned int>(i2) << static_cast<unsigned int>(i2)
<< " instead of throwing"; << " instead of throwing";
EXPECT_TRUE(false); EXPECT_TRUE(false);
} catch (std::range_error& e) { } catch (std::range_error&) {
//LOG(INFO) << e.what(); //LOG(INFO) << e.what();
} }
} }
...@@ -726,7 +726,7 @@ TEST(Conv, UnsignedEnum) { ...@@ -726,7 +726,7 @@ TEST(Conv, UnsignedEnum) {
auto i = to<int32_t>(x); auto i = to<int32_t>(x);
LOG(ERROR) << "to<int32_t> returned " << i << " instead of throwing"; LOG(ERROR) << "to<int32_t> returned " << i << " instead of throwing";
EXPECT_TRUE(false); EXPECT_TRUE(false);
} catch (std::range_error& e) { } catch (std::range_error&) {
} }
} }
......
...@@ -252,7 +252,7 @@ TEST(Dynamic, Operator) { ...@@ -252,7 +252,7 @@ TEST(Dynamic, Operator) {
LOG(ERROR) << "operator < returned " LOG(ERROR) << "operator < returned "
<< static_cast<int>(foo) << static_cast<int>(foo)
<< " instead of throwing"; << " instead of throwing";
} catch (std::exception const& e) { } catch (std::exception const&) {
caught = true; caught = true;
} }
EXPECT_TRUE(caught); EXPECT_TRUE(caught);
......
...@@ -196,7 +196,7 @@ TEST(LifoSem, shutdown_race) { ...@@ -196,7 +196,7 @@ TEST(LifoSem, shutdown_race) {
a.wait(); a.wait();
++waitCount; ++waitCount;
} }
} catch (ShutdownSemError& x) { } catch (ShutdownSemError&) {
// expected // expected
EXPECT_TRUE(a.isShutdown()); EXPECT_TRUE(a.isShutdown());
} }
...@@ -228,7 +228,7 @@ TEST(LifoSem, shutdown_multi) { ...@@ -228,7 +228,7 @@ TEST(LifoSem, shutdown_multi) {
try { try {
a.wait(); a.wait();
EXPECT_TRUE(false); EXPECT_TRUE(false);
} catch (ShutdownSemError& x) { } catch (ShutdownSemError&) {
// expected // expected
EXPECT_TRUE(a.isShutdown()); EXPECT_TRUE(a.isShutdown());
} }
......
...@@ -437,7 +437,7 @@ TEST(PrettyToDouble, Basic) { ...@@ -437,7 +437,7 @@ TEST(PrettyToDouble, Basic) {
try{ try{
recoveredX = prettyToDouble(prettyPrint(x, formatType, addSpace), recoveredX = prettyToDouble(prettyPrint(x, formatType, addSpace),
formatType); formatType);
} catch (std::range_error &ex){ } catch (std::range_error&) {
EXPECT_TRUE(false); EXPECT_TRUE(false);
} }
double relativeError = (x - recoveredX) / x; double relativeError = (x - recoveredX) / x;
......
...@@ -347,7 +347,7 @@ TEST(Uri, Simple) { ...@@ -347,7 +347,7 @@ TEST(Uri, Simple) {
try { try {
Uri u(s); Uri u(s);
CHECK(false) << "Control should not have reached here"; CHECK(false) << "Control should not have reached here";
} catch (const std::invalid_argument& ex) { } catch (const std::invalid_argument&) {
// success // success
} }
} }
...@@ -358,7 +358,7 @@ TEST(Uri, Simple) { ...@@ -358,7 +358,7 @@ TEST(Uri, Simple) {
try { try {
Uri u(s); Uri u(s);
CHECK(false) << "Control should not have reached here"; CHECK(false) << "Control should not have reached here";
} catch (const std::invalid_argument& ex) { } catch (const std::invalid_argument&) {
// success // success
} }
} }
...@@ -369,7 +369,7 @@ TEST(Uri, Simple) { ...@@ -369,7 +369,7 @@ TEST(Uri, Simple) {
try { try {
Uri u(s); Uri u(s);
CHECK(false) << "Control should not have reached here"; CHECK(false) << "Control should not have reached here";
} catch (const std::invalid_argument& ex) { } catch (const std::invalid_argument&) {
// success // success
} }
} }
...@@ -380,7 +380,7 @@ TEST(Uri, Simple) { ...@@ -380,7 +380,7 @@ TEST(Uri, Simple) {
try { try {
Uri u(s); Uri u(s);
CHECK(false) << "Control should not have reached here"; CHECK(false) << "Control should not have reached here";
} catch (const std::invalid_argument& ex) { } catch (const std::invalid_argument&) {
// success // success
} }
} }
......
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