diff options
author | Mathias Stearn <mathias@10gen.com> | 2017-08-10 15:52:33 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2017-08-16 16:28:02 -0400 |
commit | 347935f7a5d0452146b1a73ad7ef9e249eaf1fb5 (patch) | |
tree | 00b322f5adcf3eb9c2624747a6b5b2179e440052 /src/mongo/client | |
parent | cdf7aacb213c99d3ce620761ff46b030bbd7732d (diff) | |
download | mongo-347935f7a5d0452146b1a73ad7ef9e249eaf1fb5.tar.gz |
SERVER-30580 Eliminate UserException and MsgAssertionException types
All users were converted to just use AssertionException.
Diffstat (limited to 'src/mongo/client')
-rw-r--r-- | src/mongo/client/connpool.h | 2 | ||||
-rw-r--r-- | src/mongo/client/dbclient.cpp | 6 | ||||
-rw-r--r-- | src/mongo/client/dbclient_rs.cpp | 4 | ||||
-rw-r--r-- | src/mongo/client/dbclientinterface.h | 6 | ||||
-rw-r--r-- | src/mongo/client/fetcher_test.cpp | 12 | ||||
-rw-r--r-- | src/mongo/client/index_spec_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/client/remote_command_retry_scheduler_test.cpp | 16 | ||||
-rw-r--r-- | src/mongo/client/sasl_client_authenticate.cpp | 2 | ||||
-rw-r--r-- | src/mongo/client/scoped_db_conn_test.cpp | 2 |
9 files changed, 26 insertions, 26 deletions
diff --git a/src/mongo/client/connpool.h b/src/mongo/client/connpool.h index 0839e20729d..68af31a5225 100644 --- a/src/mongo/client/connpool.h +++ b/src/mongo/client/connpool.h @@ -382,7 +382,7 @@ private: class ScopedDbConnection : public AScopedConnection { public: /** the main constructor you want to use - throws UserException if can't connect + throws AssertionException if can't connect */ explicit ScopedDbConnection(const std::string& host, double socketTimeout = 0); explicit ScopedDbConnection(const ConnectionString& host, double socketTimeout = 0); diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp index dea262bf713..6f57372e40e 100644 --- a/src/mongo/client/dbclient.cpp +++ b/src/mongo/client/dbclient.cpp @@ -449,7 +449,7 @@ bool DBClientBase::authenticateInternalUser() { try { auth(getInternalUserAuthParams()); return true; - } catch (const UserException& ex) { + } catch (const AssertionException& ex) { if (!serverGlobalParams.quiet.load()) { log() << "can't authenticate to " << toString() << " as internal user, error: " << ex.what(); @@ -472,7 +472,7 @@ bool DBClientBase::auth(const string& dbname, auth::buildAuthParams(dbname, username, password_text, digestPassword); auth(authParams); return true; - } catch (const UserException& ex) { + } catch (const AssertionException& ex) { if (ex.code() != ErrorCodes::AuthenticationFailed) throw; errmsg = ex.what(); @@ -967,7 +967,7 @@ void DBClientConnection::_checkConnection() { for (map<string, BSONObj>::const_iterator i = authCache.begin(); i != authCache.end(); i++) { try { DBClientConnection::_auth(i->second); - } catch (UserException& ex) { + } catch (AssertionException& ex) { if (ex.code() != ErrorCodes::AuthenticationFailed) throw; LOG(_logLevel) << "reconnect: auth failed " diff --git a/src/mongo/client/dbclient_rs.cpp b/src/mongo/client/dbclient_rs.cpp index 2803536e397..13d706b7cd6 100644 --- a/src/mongo/client/dbclient_rs.cpp +++ b/src/mongo/client/dbclient_rs.cpp @@ -367,7 +367,7 @@ void DBClientReplicaSet::_authConnection(DBClientConnection* conn) { for (map<string, BSONObj>::const_iterator i = _auths.begin(); i != _auths.end(); ++i) { try { conn->auth(i->second); - } catch (const UserException&) { + } catch (const AssertionException&) { warning() << "cached auth failed for set: " << _setName << " db: " << i->second[saslCommandUserDBFieldName].str() << " user: " << i->second[saslCommandUserFieldName].str() << endl; @@ -380,7 +380,7 @@ void DBClientReplicaSet::logoutAll(DBClientConnection* conn) { BSONObj response; try { conn->logout(i->first, response); - } catch (const UserException& ex) { + } catch (const AssertionException& ex) { warning() << "Failed to logout: " << conn->getServerAddress() << " on db: " << i->first << causedBy(redact(ex)); } diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h index f57618bca00..91e7033379d 100644 --- a/src/mongo/client/dbclientinterface.h +++ b/src/mongo/client/dbclientinterface.h @@ -580,7 +580,7 @@ public: /** Create an index on the collection 'ns' as described by the given keys. If you wish * to specify options, see the more flexible overload of 'createIndex' which takes an * IndexSpec object. Failure to construct the index is reported by throwing a - * UserException. + * AssertionException. * * @param ns Namespace on which to create the index * @param keys Document describing keys and index types. You must provide at least one @@ -592,7 +592,7 @@ public: /** Create an index on the collection 'ns' as described by the given * descriptor. Failure to construct the index is reported by throwing a - * UserException. + * AssertionException. * * @param ns Namespace on which to create the index * @param descriptor Configuration object describing the index to create. The @@ -871,7 +871,7 @@ public: Status connectSocketOnly(const HostAndPort& server); /** Connect to a Mongo database server. Exception throwing version. - Throws a UserException if cannot connect. + Throws a AssertionException if cannot connect. If autoReconnect is true, you can try to use the DBClientConnection even when false was returned -- it will try to connect again. diff --git a/src/mongo/client/fetcher_test.cpp b/src/mongo/client/fetcher_test.cpp index a10baecd052..e68a528b041 100644 --- a/src/mongo/client/fetcher_test.cpp +++ b/src/mongo/client/fetcher_test.cpp @@ -205,32 +205,32 @@ TEST_F(FetcherTest, InvalidConstruction) { // Null executor. ASSERT_THROWS_CODE_AND_WHAT(Fetcher(nullptr, source, "db", findCmdObj, unreachableCallback), - UserException, + AssertionException, ErrorCodes::BadValue, "task executor cannot be null"); // Empty source. ASSERT_THROWS_CODE_AND_WHAT( Fetcher(&executor, HostAndPort(), "db", findCmdObj, unreachableCallback), - UserException, + AssertionException, ErrorCodes::BadValue, "source in remote command request cannot be empty"); // Empty database name. ASSERT_THROWS_CODE_AND_WHAT(Fetcher(&executor, source, "", findCmdObj, unreachableCallback), - UserException, + AssertionException, ErrorCodes::BadValue, "database name in remote command request cannot be empty"); // Empty command object. ASSERT_THROWS_CODE_AND_WHAT(Fetcher(&executor, source, "db", BSONObj(), unreachableCallback), - UserException, + AssertionException, ErrorCodes::BadValue, "command object in remote command request cannot be empty"); // Callback function cannot be null. ASSERT_THROWS_CODE_AND_WHAT(Fetcher(&executor, source, "db", findCmdObj, Fetcher::CallbackFn()), - UserException, + AssertionException, ErrorCodes::BadValue, "callback function cannot be null"); @@ -244,7 +244,7 @@ TEST_F(FetcherTest, InvalidConstruction) { rpc::makeEmptyMetadata(), RemoteCommandRequest::kNoTimeout, std::unique_ptr<RemoteCommandRetryScheduler::RetryPolicy>()), - UserException, + AssertionException, ErrorCodes::BadValue, "retry policy cannot be null"); } diff --git a/src/mongo/client/index_spec_test.cpp b/src/mongo/client/index_spec_test.cpp index 65821df91e5..7326bc2d373 100644 --- a/src/mongo/client/index_spec_test.cpp +++ b/src/mongo/client/index_spec_test.cpp @@ -32,7 +32,7 @@ #include "mongo/unittest/unittest.h" -#define ASSERT_UASSERTS(STATEMENT) ASSERT_THROWS(STATEMENT, UserException) +#define ASSERT_UASSERTS(STATEMENT) ASSERT_THROWS(STATEMENT, AssertionException) namespace mongo { diff --git a/src/mongo/client/remote_command_retry_scheduler_test.cpp b/src/mongo/client/remote_command_retry_scheduler_test.cpp index d040d72ba19..6b7e844db12 100644 --- a/src/mongo/client/remote_command_retry_scheduler_test.cpp +++ b/src/mongo/client/remote_command_retry_scheduler_test.cpp @@ -206,7 +206,7 @@ TEST_F(RemoteCommandRetrySchedulerTest, InvalidConstruction) { // Null executor. ASSERT_THROWS_CODE_AND_WHAT( RemoteCommandRetryScheduler(nullptr, request, callback, makeRetryPolicy()), - UserException, + AssertionException, ErrorCodes::BadValue, "task executor cannot be null"); @@ -217,7 +217,7 @@ TEST_F(RemoteCommandRetrySchedulerTest, InvalidConstruction) { executor::RemoteCommandRequest(HostAndPort(), request.dbname, request.cmdObj, nullptr), callback, makeRetryPolicy()), - UserException, + AssertionException, ErrorCodes::BadValue, "source in remote command request cannot be empty"); @@ -228,7 +228,7 @@ TEST_F(RemoteCommandRetrySchedulerTest, InvalidConstruction) { executor::RemoteCommandRequest(request.target, "", request.cmdObj, nullptr), callback, makeRetryPolicy()), - UserException, + AssertionException, ErrorCodes::BadValue, "database name in remote command request cannot be empty"); @@ -239,7 +239,7 @@ TEST_F(RemoteCommandRetrySchedulerTest, InvalidConstruction) { executor::RemoteCommandRequest(request.target, request.dbname, BSONObj(), nullptr), callback, makeRetryPolicy()), - UserException, + AssertionException, ErrorCodes::BadValue, "command object in remote command request cannot be empty"); @@ -249,7 +249,7 @@ TEST_F(RemoteCommandRetrySchedulerTest, InvalidConstruction) { request, executor::TaskExecutor::RemoteCommandCallbackFn(), makeRetryPolicy()), - UserException, + AssertionException, ErrorCodes::BadValue, "remote command callback function cannot be null"); @@ -259,7 +259,7 @@ TEST_F(RemoteCommandRetrySchedulerTest, InvalidConstruction) { request, callback, std::unique_ptr<RemoteCommandRetryScheduler::RetryPolicy>()), - UserException, + AssertionException, ErrorCodes::BadValue, "retry policy cannot be null"); @@ -270,7 +270,7 @@ TEST_F(RemoteCommandRetrySchedulerTest, InvalidConstruction) { request, callback, RemoteCommandRetryScheduler::makeRetryPolicy(0, Milliseconds(100), {})), - UserException, + AssertionException, ErrorCodes::BadValue, "policy max attempts cannot be zero"); @@ -281,7 +281,7 @@ TEST_F(RemoteCommandRetrySchedulerTest, InvalidConstruction) { request, callback, RemoteCommandRetryScheduler::makeRetryPolicy(1U, Milliseconds(-100), {})), - UserException, + AssertionException, ErrorCodes::BadValue, "policy max response elapsed total cannot be negative"); } diff --git a/src/mongo/client/sasl_client_authenticate.cpp b/src/mongo/client/sasl_client_authenticate.cpp index 1d305d44d05..13e0b4ee3fa 100644 --- a/src/mongo/client/sasl_client_authenticate.cpp +++ b/src/mongo/client/sasl_client_authenticate.cpp @@ -79,7 +79,7 @@ Status saslExtractPayload(const BSONObj& cmdObj, std::string* payload, BSONType* } else if (payloadElement.type() == String) { try { *payload = base64::decode(payloadElement.str()); - } catch (UserException& e) { + } catch (AssertionException& e) { return Status(ErrorCodes::FailedToParse, e.what()); } } else { diff --git a/src/mongo/client/scoped_db_conn_test.cpp b/src/mongo/client/scoped_db_conn_test.cpp index c26428c7539..19ee06fae9f 100644 --- a/src/mongo/client/scoped_db_conn_test.cpp +++ b/src/mongo/client/scoped_db_conn_test.cpp @@ -421,7 +421,7 @@ TEST_F(DummyServerFixture, ScopedDbConnectionWithTimeout) { log() << "Testing MongoURI with explicit timeout"; start = Date_t::now(); - ASSERT_THROWS(ScopedDbConnection conn4(uri, overrideTimeout.count()), UserException); + ASSERT_THROWS(ScopedDbConnection conn4(uri, overrideTimeout.count()), AssertionException); end = Date_t::now(); ASSERT_GTE((end - start) + gracePeriod, overrideTimeout); ASSERT_LT(end - start, uriTimeout); |