From 8fccaecc28ed1ad0747e516a6f0cb1d350406798 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Mon, 26 Apr 2010 14:34:39 +0200 Subject: [PATCH] Don't catch unknown exceptions if we are only going to rethrow them. Rethrowing hides the real source of the exception. --- src/command_client.cpp | 8 -------- src/command_server.cpp | 8 -------- src/socket_server.cpp | 2 -- src/socket_wrapper.cpp | 8 -------- test/cmdgroup.cpp | 2 -- test/newserver.cpp | 2 -- test/serialize.cpp | 2 -- test/simplecmd.cpp | 2 -- test/timeout.cpp | 8 -------- 9 files changed, 0 insertions(+), 42 deletions(-) diff --git a/src/command_client.cpp b/src/command_client.cpp index 9945a5a..5d618b2 100644 --- a/src/command_client.cpp +++ b/src/command_client.cpp @@ -72,10 +72,6 @@ command_client::command_client(client_connection* _c, long long _command_timeout // store a copy of the exception that you can find out details about the error later constructorException = e.clone(); } - catch (...) - { - throw; - } } } @@ -271,8 +267,6 @@ void command_client::send_command(command* cmd, result_container &res) msg << "archive_exception while serializing on client-side, code " << e.code << " (" << e.what() << ")"; throw t2n_serialization_error(msg.str()); } - catch(...) - { throw; } std::ostream* ostr; if ((ostr=c->get_logstream(fulldebug))!=NULL) @@ -297,8 +291,6 @@ void command_client::send_command(command* cmd, result_container &res) msg << "archive_exception while deserializing on client-side, code " << e.code << " (" << e.what() << ")"; throw t2n_serialization_error(msg.str()); } - catch(...) - { throw; } if ((ostr=c->get_logstream(fulldebug))!=NULL) { diff --git a/src/command_server.cpp b/src/command_server.cpp index 2bb6521..1db24a4 100644 --- a/src/command_server.cpp +++ b/src/command_server.cpp @@ -102,8 +102,6 @@ void command_server::handle_packet(const std::string& packet, server_connection* "code " << e.code << " (" << e.what() << ")"; res.set_exception(new t2n_serialization_error(msg.str())); } - catch(...) - { throw; } if (!res.has_exception()) { @@ -125,8 +123,6 @@ void command_server::handle_packet(const std::string& packet, server_connection* } catch (t2n_exception &e) { res.set_exception(e.clone()); } - catch (...) - { throw; } } else { @@ -154,8 +150,6 @@ void command_server::handle_packet(const std::string& packet, server_connection* res.set_exception(new t2n_serialization_error(msg.str())); oa << res; } - catch(...) - { throw; } std::ostream* ostr; if ((ostr=s.get_logstream(fulldebug))!=NULL) @@ -196,8 +190,6 @@ void command_server::handle(long long usec_timeout, long long* usec_timeout_rema // shut down a connection with transfer errors (usually write errors) conn->close(); } - catch(...) - { throw; } } } } diff --git a/src/socket_server.cpp b/src/socket_server.cpp index 7c6f244..35bb314 100644 --- a/src/socket_server.cpp +++ b/src/socket_server.cpp @@ -277,8 +277,6 @@ bool socket_server::fill_connection_buffers() } catch (t2n_transfer_error &e) { i->second->close(); } - catch(...) - { throw; } } return data_found; diff --git a/src/socket_wrapper.cpp b/src/socket_wrapper.cpp index 89521bc..50ec75f 100644 --- a/src/socket_wrapper.cpp +++ b/src/socket_wrapper.cpp @@ -87,10 +87,6 @@ bool ReconnectSocketWrapper::handle(command_client* stubBase, boost::function< v // otherwise ignore the exception and reconnect in the next iteration } - catch(...) - { - throw; - } tries++; } @@ -141,10 +137,6 @@ bool ReconnectIgnoreFailureSocketWrapper::handle(command_client* stubBase, boost { // ignore } - catch(...) - { - throw; - } } return false; diff --git a/test/cmdgroup.cpp b/test/cmdgroup.cpp index 1c30cc3..942fd88 100644 --- a/test/cmdgroup.cpp +++ b/test/cmdgroup.cpp @@ -271,8 +271,6 @@ BOOST_AUTO_TEST_CASE(WrongGroup) } catch(t2n_command_error &e) { ret=e.what(); } - catch(...) - { throw; } string expected_what="illegal command of type "; diff --git a/test/newserver.cpp b/test/newserver.cpp index 32f4d96..5fa21b4 100644 --- a/test/newserver.cpp +++ b/test/newserver.cpp @@ -193,8 +193,6 @@ BOOST_AUTO_TEST_CASE(NewServerSocket) } catch(t2n_transfer_error &e) { errormsg=e.what(); } - catch(...) - { throw; } bool test_fine=false; if (errormsg == "write() returned Bad file descriptor" diff --git a/test/serialize.cpp b/test/serialize.cpp index 598ac4b..3019952 100644 --- a/test/serialize.cpp +++ b/test/serialize.cpp @@ -171,8 +171,6 @@ BOOST_AUTO_TEST_CASE(ClientSerializeErr) } catch(t2n_serialization_error &e) { errormsg=e.what(); } - catch(...) - { throw; } BOOST_CHECK_EQUAL(string("archive_exception while serializing on client-side, code 2 (unregistered class)"),errormsg); } diff --git a/test/simplecmd.cpp b/test/simplecmd.cpp index 11de9ca..97fa6da 100644 --- a/test/simplecmd.cpp +++ b/test/simplecmd.cpp @@ -224,8 +224,6 @@ BOOST_AUTO_TEST_CASE(SimpleException) } catch(t2n_runtime_error &e) { ret=e.what(); } - catch(...) - { throw; } BOOST_CHECK_EQUAL(string("throw me around"),ret); } diff --git a/test/timeout.cpp b/test/timeout.cpp index 8f67cac..c85d43e 100644 --- a/test/timeout.cpp +++ b/test/timeout.cpp @@ -370,8 +370,6 @@ BOOST_AUTO_TEST_CASE(CommandTimeout) } catch(t2n_transfer_error &e) { errormsg=e.what(); } - catch(...) - { throw; } BOOST_CHECK_EQUAL(string("timeout exceeded"),errormsg); } @@ -449,8 +447,6 @@ BOOST_AUTO_TEST_CASE(CommandSlowResponse) } catch(t2n_transfer_error &e) { errormsg=e.what(); } - catch(...) - { throw; } BOOST_CHECK_EQUAL(string("timeout exceeded"),errormsg); } @@ -506,8 +502,6 @@ BOOST_AUTO_TEST_CASE(DisconnectOnWrite) } catch(t2n_transfer_error &e) { errormsg=e.what(); } - catch(...) - { throw; } BOOST_CHECK_EQUAL(string("write() returned Broken pipe"),errormsg); } @@ -569,8 +563,6 @@ BOOST_AUTO_TEST_CASE(WriteTwice) } catch(t2n_transfer_error &e) { errormsg=e.what(); } - catch(...) - { throw; } BOOST_CHECK_EQUAL(string("write() returned Broken pipe"),errormsg); } -- 1.7.1