summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2017-08-10 15:52:33 -0400
committerMathias Stearn <mathias@10gen.com>2017-08-16 16:28:02 -0400
commit347935f7a5d0452146b1a73ad7ef9e249eaf1fb5 (patch)
tree00b322f5adcf3eb9c2624747a6b5b2179e440052
parentcdf7aacb213c99d3ce620761ff46b030bbd7732d (diff)
downloadmongo-347935f7a5d0452146b1a73ad7ef9e249eaf1fb5.tar.gz
SERVER-30580 Eliminate UserException and MsgAssertionException types
All users were converted to just use AssertionException.
-rwxr-xr-xbuildscripts/errorcodes.py2
-rw-r--r--src/mongo/bson/bsonelement.h2
-rw-r--r--src/mongo/bson/json.cpp4
-rw-r--r--src/mongo/bson/json.h2
-rw-r--r--src/mongo/client/connpool.h2
-rw-r--r--src/mongo/client/dbclient.cpp6
-rw-r--r--src/mongo/client/dbclient_rs.cpp4
-rw-r--r--src/mongo/client/dbclientinterface.h6
-rw-r--r--src/mongo/client/fetcher_test.cpp12
-rw-r--r--src/mongo/client/index_spec_test.cpp2
-rw-r--r--src/mongo/client/remote_command_retry_scheduler_test.cpp16
-rw-r--r--src/mongo/client/sasl_client_authenticate.cpp2
-rw-r--r--src/mongo/client/scoped_db_conn_test.cpp2
-rw-r--r--src/mongo/db/auth/authorization_session_test.cpp2
-rw-r--r--src/mongo/db/catalog/database_test.cpp9
-rw-r--r--src/mongo/db/catalog/drop_database_test.cpp2
-rw-r--r--src/mongo/db/catalog/namespace_uuid_cache.h2
-rw-r--r--src/mongo/db/catalog/namespace_uuid_cache_test.cpp2
-rw-r--r--src/mongo/db/commands/eval.cpp2
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp2
-rw-r--r--src/mongo/db/commands/mr_test.cpp15
-rw-r--r--src/mongo/db/commands/parameters.cpp4
-rw-r--r--src/mongo/db/commands/validate.cpp2
-rw-r--r--src/mongo/db/concurrency/fast_map_noalloc_test.cpp5
-rw-r--r--src/mongo/db/cursor_manager.h6
-rw-r--r--src/mongo/db/dbmessage_test.cpp12
-rw-r--r--src/mongo/db/exec/group.cpp10
-rw-r--r--src/mongo/db/fts/fts_index_format_test.cpp10
-rw-r--r--src/mongo/db/fts/fts_spec_test.cpp2
-rw-r--r--src/mongo/db/geo/hash_test.cpp4
-rw-r--r--src/mongo/db/index/btree_key_generator_test.cpp20
-rw-r--r--src/mongo/db/index/index_access_method.cpp2
-rw-r--r--src/mongo/db/index/sort_key_generator.cpp2
-rw-r--r--src/mongo/db/keypattern_test.cpp6
-rw-r--r--src/mongo/db/logical_session_id_test.cpp12
-rw-r--r--src/mongo/db/matcher/copyable_match_expression.h4
-rw-r--r--src/mongo/db/matcher/expression_parser_geo_test.cpp22
-rw-r--r--src/mongo/db/matcher/expression_parser_leaf_test.cpp2
-rw-r--r--src/mongo/db/operation_context.h4
-rw-r--r--src/mongo/db/ops/write_ops_exec.cpp10
-rw-r--r--src/mongo/db/ops/write_ops_parsers_test.cpp25
-rw-r--r--src/mongo/db/pipeline/accumulation_statement.h2
-rw-r--r--src/mongo/db/pipeline/aggregation_request_test.cpp14
-rw-r--r--src/mongo/db/pipeline/document.h3
-rw-r--r--src/mongo/db/pipeline/document_source_add_fields_test.cpp7
-rw-r--r--src/mongo/db/pipeline/document_source_bucket_auto_test.cpp56
-rw-r--r--src/mongo/db/pipeline/document_source_bucket_test.cpp50
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream_test.cpp8
-rw-r--r--src/mongo/db/pipeline/document_source_check_resume_token_test.cpp8
-rw-r--r--src/mongo/db/pipeline/document_source_count_test.cpp12
-rw-r--r--src/mongo/db/pipeline/document_source_current_op_test.cpp18
-rw-r--r--src/mongo/db/pipeline/document_source_facet.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_facet_test.cpp53
-rw-r--r--src/mongo/db/pipeline/document_source_graph_lookup_test.cpp6
-rw-r--r--src/mongo/db/pipeline/document_source_group.h2
-rw-r--r--src/mongo/db/pipeline/document_source_group_test.cpp10
-rw-r--r--src/mongo/db/pipeline/document_source_lookup_change_post_image.h2
-rw-r--r--src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp12
-rw-r--r--src/mongo/db/pipeline/document_source_lookup_test.cpp10
-rw-r--r--src/mongo/db/pipeline/document_source_project_test.cpp5
-rw-r--r--src/mongo/db/pipeline/document_source_replace_root_test.cpp33
-rw-r--r--src/mongo/db/pipeline/document_source_sample_test.cpp20
-rw-r--r--src/mongo/db/pipeline/document_source_skip.h2
-rw-r--r--src/mongo/db/pipeline/document_source_sort_by_count_test.cpp8
-rw-r--r--src/mongo/db/pipeline/document_source_sort_test.cpp12
-rw-r--r--src/mongo/db/pipeline/document_source_unwind_test.cpp25
-rw-r--r--src/mongo/db/pipeline/document_value_test.cpp23
-rw-r--r--src/mongo/db/pipeline/expression_test.cpp94
-rw-r--r--src/mongo/db/pipeline/field_path.h5
-rw-r--r--src/mongo/db/pipeline/field_path_test.cpp22
-rw-r--r--src/mongo/db/pipeline/granularity_rounder_powers_of_two_test.cpp20
-rw-r--r--src/mongo/db/pipeline/granularity_rounder_preferred_numbers_test.cpp24
-rw-r--r--src/mongo/db/pipeline/lite_parsed_document_source.h3
-rw-r--r--src/mongo/db/pipeline/lite_parsed_pipeline.h2
-rw-r--r--src/mongo/db/pipeline/parsed_add_fields_test.cpp43
-rw-r--r--src/mongo/db/pipeline/parsed_aggregation_projection.cpp4
-rw-r--r--src/mongo/db/pipeline/parsed_aggregation_projection.h2
-rw-r--r--src/mongo/db/pipeline/parsed_aggregation_projection_test.cpp165
-rw-r--r--src/mongo/db/pipeline/parsed_inclusion_projection_test.cpp4
-rw-r--r--src/mongo/db/pipeline/pipeline_test.cpp2
-rw-r--r--src/mongo/db/pipeline/tee_buffer_test.cpp6
-rw-r--r--src/mongo/db/pipeline/value.h6
-rw-r--r--src/mongo/db/query/collation/collation_index_key_test.cpp6
-rw-r--r--src/mongo/db/query/datetime/date_time_support.h2
-rw-r--r--src/mongo/db/query/datetime/date_time_support_test.cpp45
-rw-r--r--src/mongo/db/repl/abstract_async_component_test.cpp2
-rw-r--r--src/mongo/db/repl/collection_cloner_test.cpp10
-rw-r--r--src/mongo/db/repl/database_cloner.cpp2
-rw-r--r--src/mongo/db/repl/database_cloner_test.cpp14
-rw-r--r--src/mongo/db/repl/databases_cloner_test.cpp12
-rw-r--r--src/mongo/db/repl/initial_syncer_test.cpp4
-rw-r--r--src/mongo/db/repl/master_slave.cpp12
-rw-r--r--src/mongo/db/repl/multiapplier_test.cpp10
-rw-r--r--src/mongo/db/repl/oplog.cpp4
-rw-r--r--src/mongo/db/repl/reporter_test.cpp12
-rw-r--r--src/mongo/db/repl/roll_back_local_operations_test.cpp4
-rw-r--r--src/mongo/db/repl/rollback_checker_test.cpp3
-rw-r--r--src/mongo/db/repl/rs_rollback_no_uuid_test.cpp4
-rw-r--r--src/mongo/db/repl/rs_rollback_test.cpp4
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp2
-rw-r--r--src/mongo/db/repl/storage_interface_impl_test.cpp2
-rw-r--r--src/mongo/db/repl/sync_source_resolver_test.cpp12
-rw-r--r--src/mongo/db/repl/sync_tail_test.cpp5
-rw-r--r--src/mongo/db/repl/task_runner_test.cpp2
-rw-r--r--src/mongo/db/s/namespace_metadata_change_notifications_test.cpp6
-rw-r--r--src/mongo/db/s/type_shard_identity.cpp2
-rw-r--r--src/mongo/db/service_entry_point_mongod.cpp8
-rw-r--r--src/mongo/db/session_test.cpp10
-rw-r--r--src/mongo/db/storage/kv/kv_engine_test_snapshots.cpp2
-rw-r--r--src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp10
-rw-r--r--src/mongo/db/storage/mmap_v1/dur_journal.cpp2
-rw-r--r--src/mongo/db/storage/recovery_unit.h8
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp4
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_parameters.cpp2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp2
-rw-r--r--src/mongo/db/transaction_history_iterator_test.cpp5
-rw-r--r--src/mongo/db/update/addtoset_node_test.cpp2
-rw-r--r--src/mongo/db/update/arithmetic_node_test.cpp12
-rw-r--r--src/mongo/db/update/object_replace_node_test.cpp12
-rw-r--r--src/mongo/db/update/pop_node_test.cpp10
-rw-r--r--src/mongo/db/update/pull_node.cpp2
-rw-r--r--src/mongo/db/update/pull_node_test.cpp8
-rw-r--r--src/mongo/db/update/pullall_node_test.cpp2
-rw-r--r--src/mongo/db/update/push_node_test.cpp2
-rw-r--r--src/mongo/db/update/rename_node_test.cpp24
-rw-r--r--src/mongo/db/update/set_node_test.cpp30
-rw-r--r--src/mongo/db/update/unset_node_test.cpp8
-rw-r--r--src/mongo/db/update/update_array_node_test.cpp12
-rw-r--r--src/mongo/db/update/update_driver_test.cpp8
-rw-r--r--src/mongo/db/update/update_leaf_node.h2
-rw-r--r--src/mongo/db/update/update_node.h4
-rw-r--r--src/mongo/db/update/update_object_node_test.cpp28
-rw-r--r--src/mongo/db/views/resolved_view_test.cpp12
-rw-r--r--src/mongo/db/views/view_catalog_test.cpp2
-rw-r--r--src/mongo/dbtests/clienttests.cpp3
-rw-r--r--src/mongo/dbtests/directclienttests.cpp7
-rw-r--r--src/mongo/dbtests/gle_test.cpp2
-rw-r--r--src/mongo/dbtests/indexupdatetests.cpp5
-rw-r--r--src/mongo/dbtests/jsobjtests.cpp10
-rw-r--r--src/mongo/dbtests/jsontests.cpp2
-rw-r--r--src/mongo/dbtests/jstests.cpp10
-rw-r--r--src/mongo/dbtests/query_plan_executor.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_tests.cpp2
-rw-r--r--src/mongo/dbtests/querytests.cpp12
-rw-r--r--src/mongo/dbtests/validate_tests.cpp2
-rw-r--r--src/mongo/idl/idl_test.cpp95
-rw-r--r--src/mongo/rpc/command_reply_test.cpp8
-rw-r--r--src/mongo/rpc/command_request_test.cpp4
-rw-r--r--src/mongo/rpc/metadata_test.cpp12
-rw-r--r--src/mongo/s/async_requests_sender.cpp2
-rw-r--r--src/mongo/s/catalog/sharding_catalog_shard_collection_test.cpp2
-rw-r--r--src/mongo/s/client/parallel.cpp2
-rw-r--r--src/mongo/s/client/sharding_connection_hook.cpp4
-rw-r--r--src/mongo/s/stale_exception.h7
-rw-r--r--src/mongo/shell/bench.cpp2
-rw-r--r--src/mongo/shell/shell_options.cpp12
-rw-r--r--src/mongo/util/assert_util.cpp13
-rw-r--r--src/mongo/util/assert_util.h33
-rw-r--r--src/mongo/util/background_job_test.cpp2
-rw-r--r--src/mongo/util/base64_test.cpp2
-rw-r--r--src/mongo/util/decorable_test.cpp2
-rw-r--r--src/mongo/util/duration.h8
-rw-r--r--src/mongo/util/duration_test.cpp36
-rw-r--r--src/mongo/util/net/op_msg_test.cpp43
-rw-r--r--src/mongo/util/options_parser/value.h4
-rw-r--r--src/mongo/util/uuid.cpp2
166 files changed, 920 insertions, 913 deletions
diff --git a/buildscripts/errorcodes.py b/buildscripts/errorcodes.py
index 1158406d460..3c80fc1f551 100755
--- a/buildscripts/errorcodes.py
+++ b/buildscripts/errorcodes.py
@@ -57,7 +57,7 @@ def parseSourceFiles( callback ):
patterns = [
re.compile( r"(?:u|m(?:sg)?)asser(?:t|ted)(?:NoTrace)?\s*\(\s*(\d+)", re.MULTILINE ) ,
- re.compile( r"(?:User|Msg|MsgAssertion)Exception\s*\(\s*(\d+)", re.MULTILINE ),
+ re.compile( r"(?:DB|Assertion)Exception\s*\(\s*(\d+)", re.MULTILINE ),
re.compile( r"fassert(?:Failed)?(?:WithStatus)?(?:NoTrace)?(?:StatusOK)?\s*\(\s*(\d+)",
re.MULTILINE ),
]
diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h
index 6b605fffd71..7d58f4653aa 100644
--- a/src/mongo/bson/bsonelement.h
+++ b/src/mongo/bson/bsonelement.h
@@ -134,7 +134,7 @@ public:
Note the returned object is a reference to within the parent bson object. If that
object is out of scope, this pointer will no longer be valid. Call getOwned() on the
returned BSONObj if you need your own copy.
- throws UserException if the element is not of type object.
+ throws AssertionException if the element is not of type object.
*/
BSONObj Obj() const;
diff --git a/src/mongo/bson/json.cpp b/src/mongo/bson/json.cpp
index 647accf31ba..5e132e1e5b3 100644
--- a/src/mongo/bson/json.cpp
+++ b/src/mongo/bson/json.cpp
@@ -1302,13 +1302,13 @@ BSONObj fromjson(const char* jsonString, int* len) {
} catch (std::exception& e) {
std::ostringstream message;
message << "caught exception from within JSON parser: " << e.what();
- throw MsgAssertionException(17031, message.str());
+ throw AssertionException(17031, message.str());
}
if (ret != Status::OK()) {
ostringstream message;
message << "code " << ret.code() << ": " << ret.codeString() << ": " << ret.reason();
- throw MsgAssertionException(16619, message.str());
+ throw AssertionException(16619, message.str());
}
if (len)
*len = jparse.offset();
diff --git a/src/mongo/bson/json.h b/src/mongo/bson/json.h
index 81bf78ace36..abc27f6daf6 100644
--- a/src/mongo/bson/json.h
+++ b/src/mongo/bson/json.h
@@ -45,7 +45,7 @@ namespace mongo {
* quotes. JSON unicode escape sequences (of the form \uXXXX) are
* converted to utf8.
*
- * @throws MsgAssertionException if parsing fails. The message included with
+ * @throws AssertionException if parsing fails. The message included with
* this assertion includes the character offset where parsing failed.
*/
BSONObj fromjson(const std::string& str);
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);
diff --git a/src/mongo/db/auth/authorization_session_test.cpp b/src/mongo/db/auth/authorization_session_test.cpp
index e6626c58576..308156c31ee 100644
--- a/src/mongo/db/auth/authorization_session_test.cpp
+++ b/src/mongo/db/auth/authorization_session_test.cpp
@@ -869,7 +869,7 @@ TEST_F(AuthorizationSessionTest, AddPrivilegesForStageFailsIfOutNamespaceIsNotVa
BSONObj cmdObj =
BSON("aggregate" << testFooNss.coll() << "pipeline" << pipeline << "cursor" << BSONObj());
ASSERT_THROWS_CODE(authzSession->checkAuthForAggregate(testFooNss, cmdObj, false).ignore(),
- UserException,
+ AssertionException,
ErrorCodes::InvalidNamespace);
}
diff --git a/src/mongo/db/catalog/database_test.cpp b/src/mongo/db/catalog/database_test.cpp
index 40e106dceac..88411e5813e 100644
--- a/src/mongo/db/catalog/database_test.cpp
+++ b/src/mongo/db/catalog/database_test.cpp
@@ -122,7 +122,7 @@ TEST_F(DatabaseTest, SetDropPendingThrowsExceptionIfDatabaseIsAlreadyInADropPend
ASSERT_THROWS_CODE_AND_WHAT(
db->setDropPending(_opCtx.get(), true),
- UserException,
+ AssertionException,
ErrorCodes::DatabaseDropPending,
(StringBuilder() << "Unable to drop database " << _nss.db()
<< " because it is already in the process of being dropped.")
@@ -156,7 +156,7 @@ TEST_F(DatabaseTest, CreateCollectionThrowsExceptionWhenDatabaseIsInADropPending
ASSERT_THROWS_CODE_AND_WHAT(
db->createCollection(_opCtx.get(), _nss.ns()),
- UserException,
+ AssertionException,
ErrorCodes::DatabaseDropPending,
(StringBuilder() << "Cannot create collection " << _nss.ns()
<< " - database is in the process of being dropped.")
@@ -380,9 +380,8 @@ void _testDropCollectionThrowsExceptionIfThereAreIndexesInProgress(OperationCont
ASSERT_GREATER_THAN(indexCatalog->numIndexesInProgress(opCtx), 0);
WriteUnitOfWork wuow(opCtx);
- ASSERT_THROWS_CODE(db->dropCollection(opCtx, nss.ns()).transitional_ignore(),
- MsgAssertionException,
- 40461);
+ ASSERT_THROWS_CODE(
+ db->dropCollection(opCtx, nss.ns()).transitional_ignore(), AssertionException, 40461);
});
}
diff --git a/src/mongo/db/catalog/drop_database_test.cpp b/src/mongo/db/catalog/drop_database_test.cpp
index 8be4d665374..1e384c3a031 100644
--- a/src/mongo/db/catalog/drop_database_test.cpp
+++ b/src/mongo/db/catalog/drop_database_test.cpp
@@ -306,7 +306,7 @@ TEST_F(DropDatabaseTest, DropDatabaseResetsDropPendingStateOnException) {
ASSERT_TRUE(db);
ASSERT_THROWS_CODE_AND_WHAT(dropDatabase(_opCtx.get(), _nss.db().toString()).ignore(),
- UserException,
+ AssertionException,
ErrorCodes::OperationFailed,
"onDropCollection() failed");
diff --git a/src/mongo/db/catalog/namespace_uuid_cache.h b/src/mongo/db/catalog/namespace_uuid_cache.h
index 6f10d3bf80a..229e7a99d55 100644
--- a/src/mongo/db/catalog/namespace_uuid_cache.h
+++ b/src/mongo/db/catalog/namespace_uuid_cache.h
@@ -55,7 +55,7 @@ public:
/**
* This function adds the pair nss.ns(), uuid to the namespace UUID cache
* if it does not yet exist. If nss.ns() already exists in the cache with
- * a different UUID, a UserException is thrown, so we can guarantee that
+ * a different UUID, a AssertionException is thrown, so we can guarantee that
* an operation will always resolve the same name to the same collection,
* even in presence of drops and renames.
*/
diff --git a/src/mongo/db/catalog/namespace_uuid_cache_test.cpp b/src/mongo/db/catalog/namespace_uuid_cache_test.cpp
index 22034f8ee43..a8aae127aee 100644
--- a/src/mongo/db/catalog/namespace_uuid_cache_test.cpp
+++ b/src/mongo/db/catalog/namespace_uuid_cache_test.cpp
@@ -46,7 +46,7 @@ TEST(NamespaceUUIDCache, ensureNamespaceInCache) {
if (debugCollectionUUIDs) {
// Uassert if we query for existing nss and uuid that does not match.
- ASSERT_THROWS(cache.ensureNamespaceInCache(nss, uuidConflict), UserException);
+ ASSERT_THROWS(cache.ensureNamespaceInCache(nss, uuidConflict), AssertionException);
}
}
diff --git a/src/mongo/db/commands/eval.cpp b/src/mongo/db/commands/eval.cpp
index b4860f561e4..9abc1a285f2 100644
--- a/src/mongo/db/commands/eval.cpp
+++ b/src/mongo/db/commands/eval.cpp
@@ -207,7 +207,7 @@ public:
OldClientContext ctx(opCtx, dbname, false /* no shard version checking here */);
return dbEval(opCtx, dbname, cmdObj, result, errmsg);
- } catch (const UserException& ex) {
+ } catch (const AssertionException& ex) {
// Convert a stale shardVersion error to a stronger error to prevent this node or the
// sending node from believing it needs to refresh its routing table.
if (ex.code() == ErrorCodes::RecvStaleConfig) {
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp
index 1ad1878ba29..d3b2ca63078 100644
--- a/src/mongo/db/commands/getmore_cmd.cpp
+++ b/src/mongo/db/commands/getmore_cmd.cpp
@@ -451,7 +451,7 @@ public:
// FAILURE state will make getMore command close the cursor even if it's tailable.
*state = PlanExecutor::FAILURE;
return Status::OK();
- } catch (const UserException& except) {
+ } catch (const AssertionException& except) {
if (isAwaitData && except.code() == ErrorCodes::ExceededTimeLimit) {
// We ignore exceptions from interrupt points due to max time expiry for
// awaitData cursors.
diff --git a/src/mongo/db/commands/mr_test.cpp b/src/mongo/db/commands/mr_test.cpp
index 406feab7487..a3f8d95bf54 100644
--- a/src/mongo/db/commands/mr_test.cpp
+++ b/src/mongo/db/commands/mr_test.cpp
@@ -115,23 +115,24 @@ void _testConfigParseOutputOptions(const std::string& dbname,
*/
TEST(ConfigOutputOptionsTest, parseOutputOptions) {
// Missing 'out' field.
- ASSERT_THROWS(mr::Config::parseOutputOptions("mydb", fromjson("{}")), UserException);
+ ASSERT_THROWS(mr::Config::parseOutputOptions("mydb", fromjson("{}")), AssertionException);
// 'out' must be either string or object.
- ASSERT_THROWS(mr::Config::parseOutputOptions("mydb", fromjson("{out: 99}")), UserException);
+ ASSERT_THROWS(mr::Config::parseOutputOptions("mydb", fromjson("{out: 99}")),
+ AssertionException);
// 'out.nonAtomic' is not supported with normal, replace or inline.
ASSERT_THROWS(mr::Config::parseOutputOptions(
"mydb", fromjson("{out: {normal: 'mycoll', nonAtomic: true}}")),
- UserException);
+ AssertionException);
ASSERT_THROWS(mr::Config::parseOutputOptions(
"mydb", fromjson("{out: {replace: 'mycoll', nonAtomic: true}}")),
- UserException);
+ AssertionException);
ASSERT_THROWS(mr::Config::parseOutputOptions(
"mydb", fromjson("{out: {inline: 'mycoll', nonAtomic: true}}")),
- UserException);
+ AssertionException);
// Unknown output specifer.
ASSERT_THROWS(
mr::Config::parseOutputOptions("mydb", fromjson("{out: {no_such_out_type: 'mycoll'}}")),
- UserException);
+ AssertionException);
// 'out' is string.
@@ -251,7 +252,7 @@ TEST(ConfigTest, CollationNotAnObjectFailsToParse) {
bob.append("out", "outCollection");
bob.append("collation", "en_US");
BSONObj cmdObj = bob.obj();
- ASSERT_THROWS(mr::Config(dbname, cmdObj), UserException);
+ ASSERT_THROWS(mr::Config(dbname, cmdObj), AssertionException);
}
} // namespace
diff --git a/src/mongo/db/commands/parameters.cpp b/src/mongo/db/commands/parameters.cpp
index 2c0164fdae9..f75a440bb77 100644
--- a/src/mongo/db/commands/parameters.cpp
+++ b/src/mongo/db/commands/parameters.cpp
@@ -459,7 +459,7 @@ public:
virtual Status set(const BSONElement& newValueElement) {
try {
return setFromString(newValueElement.String());
- } catch (const MsgAssertionException& msg) {
+ } catch (const AssertionException& msg) {
return Status(ErrorCodes::BadValue,
mongoutils::str::stream()
<< "Invalid value for sslMode via setParameter command: "
@@ -530,7 +530,7 @@ public:
virtual Status set(const BSONElement& newValueElement) {
try {
return setFromString(newValueElement.String());
- } catch (const MsgAssertionException& msg) {
+ } catch (const AssertionException& msg) {
return Status(ErrorCodes::BadValue,
mongoutils::str::stream()
<< "Invalid value for clusterAuthMode via setParameter command: "
diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp
index 90789bd51c1..d6cedeb95d3 100644
--- a/src/mongo/db/commands/validate.cpp
+++ b/src/mongo/db/commands/validate.cpp
@@ -174,7 +174,7 @@ public:
while (_validationsInProgress.find(nss.ns()) != _validationsInProgress.end()) {
opCtx->waitForConditionOrInterrupt(_validationNotifier, lock);
}
- } catch (UserException& e) {
+ } catch (AssertionException& e) {
appendCommandStatus(
result,
{ErrorCodes::CommandFailed,
diff --git a/src/mongo/db/concurrency/fast_map_noalloc_test.cpp b/src/mongo/db/concurrency/fast_map_noalloc_test.cpp
index 18efc4b0595..d03d1d59fc1 100644
--- a/src/mongo/db/concurrency/fast_map_noalloc_test.cpp
+++ b/src/mongo/db/concurrency/fast_map_noalloc_test.cpp
@@ -92,8 +92,9 @@ TEST(FastMapNoAlloc, ExceedCapacity) {
->initNew(i, "Item" + boost::lexical_cast<std::string>(i));
}
- ASSERT_THROWS_CODE(
- map.insert(ResourceId(RESOURCE_COLLECTION, 6)), UserException, ErrorCodes::TooManyLocks);
+ ASSERT_THROWS_CODE(map.insert(ResourceId(RESOURCE_COLLECTION, 6)),
+ AssertionException,
+ ErrorCodes::TooManyLocks);
}
TEST(FastMapNoAlloc, FindNonExisting) {
diff --git a/src/mongo/db/cursor_manager.h b/src/mongo/db/cursor_manager.h
index 0b243e21996..5a2aed6edc0 100644
--- a/src/mongo/db/cursor_manager.h
+++ b/src/mongo/db/cursor_manager.h
@@ -147,9 +147,9 @@ public:
* Returns ErrorCodes::CursorNotFound if the cursor does not exist or
* ErrorCodes::QueryPlanKilled if the cursor was killed in between uses.
*
- * Throws a UserException if the cursor is already pinned. Callers need not specially handle
- * this error, as it should only happen if a misbehaving client attempts to simultaneously issue
- * two operations against the same cursor id.
+ * Throws a AssertionException if the cursor is already pinned. Callers need not specially
+ * handle this error, as it should only happen if a misbehaving client attempts to
+ * simultaneously issue two operations against the same cursor id.
*/
StatusWith<ClientCursorPin> pinCursor(OperationContext* opCtx, CursorId id);
diff --git a/src/mongo/db/dbmessage_test.cpp b/src/mongo/db/dbmessage_test.cpp
index 2afd69b06ea..77775364302 100644
--- a/src/mongo/db/dbmessage_test.cpp
+++ b/src/mongo/db/dbmessage_test.cpp
@@ -45,7 +45,7 @@ TEST(DBMessage1, ShortFlags) {
Message toSend;
toSend.setData(dbDelete, b.buf(), b.len());
- ASSERT_THROWS(DbMessage d1(toSend), UserException);
+ ASSERT_THROWS(DbMessage d1(toSend), AssertionException);
}
// Test a short NS missing a trailing null
@@ -61,7 +61,7 @@ TEST(DBMessage1, BadNS) {
Message toSend;
toSend.setData(dbDelete, b.buf(), b.len());
- ASSERT_THROWS(DbMessage d1(toSend), UserException);
+ ASSERT_THROWS(DbMessage d1(toSend), AssertionException);
}
// Test a valid kill message and try an extra pull
@@ -77,7 +77,7 @@ TEST(DBMessage1, GoodKill) {
DbMessage d1(toSend);
ASSERT_EQUALS(3, d1.pullInt());
- ASSERT_THROWS(d1.pullInt(), UserException);
+ ASSERT_THROWS(d1.pullInt(), AssertionException);
}
// Try a bad read of a type too large
@@ -91,7 +91,7 @@ TEST(DBMessage1, GoodKill2) {
toSend.setData(dbKillCursors, b.buf(), b.len());
DbMessage d1(toSend);
- ASSERT_THROWS(d1.pullInt64(), UserException);
+ ASSERT_THROWS(d1.pullInt64(), AssertionException);
}
// Test a basic good insert, and an extra read
@@ -110,7 +110,7 @@ TEST(DBMessage1, GoodInsert) {
DbMessage d1(toSend);
ASSERT_EQUALS(3, d1.pullInt());
ASSERT_EQUALS(39, d1.pullInt());
- ASSERT_THROWS(d1.pullInt(), UserException);
+ ASSERT_THROWS(d1.pullInt(), AssertionException);
}
// Test a basic good insert, and an extra read
@@ -135,7 +135,7 @@ TEST(DBMessage1, GoodInsert2) {
ASSERT_EQUALS(39, d1.pullInt());
BSONObj bo2 = d1.nextJsObj();
- ASSERT_THROWS(d1.nextJsObj(), UserException);
+ ASSERT_THROWS(d1.nextJsObj(), AssertionException);
}
diff --git a/src/mongo/db/exec/group.cpp b/src/mongo/db/exec/group.cpp
index 829aacb3937..ec63e3b3b65 100644
--- a/src/mongo/db/exec/group.cpp
+++ b/src/mongo/db/exec/group.cpp
@@ -57,7 +57,7 @@ Status getKey(
const BSONObj& k = b.obj();
try {
s->invoke(func, &k, 0);
- } catch (const UserException& e) {
+ } catch (const AssertionException& e) {
return e.toStatus("Failed to invoke group keyf function: ");
}
int type = s->type("__returnValue");
@@ -106,7 +106,7 @@ Status GroupStage::initGroupScripting() {
try {
_scope->exec(
"$reduce = " + _request.reduceCode, "group reduce init", false, true, true, 2 * 1000);
- } catch (const UserException& e) {
+ } catch (const AssertionException& e) {
return e.toStatus("Failed to initialize group reduce function: ");
}
invariant(_scope->exec(
@@ -157,7 +157,7 @@ Status GroupStage::processObject(const BSONObj& obj) {
try {
_scope->invoke(_reduceFunction, 0, 0, 0, true /*assertOnError*/);
- } catch (const UserException& e) {
+ } catch (const AssertionException& e) {
return e.toStatus("Failed to invoke group reduce function: ");
}
@@ -173,7 +173,7 @@ StatusWith<BSONObj> GroupStage::finalizeResults() {
true, // reportError
true, // assertOnError
2 * 1000);
- } catch (const UserException& e) {
+ } catch (const AssertionException& e) {
return e.toStatus("Failed to initialize group finalize function: ");
}
ScriptingFunction finalizeFunction = _scope->createFunction(
@@ -186,7 +186,7 @@ StatusWith<BSONObj> GroupStage::finalizeResults() {
"}");
try {
_scope->invoke(finalizeFunction, 0, 0, 0, true /*assertOnError*/);
- } catch (const UserException& e) {
+ } catch (const AssertionException& e) {
return e.toStatus("Failed to invoke group finalize function: ");
}
}
diff --git a/src/mongo/db/fts/fts_index_format_test.cpp b/src/mongo/db/fts/fts_index_format_test.cpp
index 3a4d383bc45..4189bdeffd0 100644
--- a/src/mongo/db/fts/fts_index_format_test.cpp
+++ b/src/mongo/db/fts/fts_index_format_test.cpp
@@ -257,7 +257,7 @@ TEST(FTSIndexFormat, GetKeysWithLeadingEmptyArrayThrows) {
BSONObjSet keys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
BSONObj objToIndex = fromjson("{a: {b: []}, data: 'foo'}");
ASSERT_THROWS_CODE(FTSIndexFormat::getKeys(spec, objToIndex, &keys),
- UserException,
+ AssertionException,
ErrorCodes::CannotBuildIndexKeys);
}
@@ -267,7 +267,7 @@ TEST(FTSIndexFormat, GetKeysWithTrailingEmptyArrayThrows) {
BSONObjSet keys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
BSONObj objToIndex = fromjson("{a: {b: []}, data: 'foo'}");
ASSERT_THROWS_CODE(FTSIndexFormat::getKeys(spec, objToIndex, &keys),
- UserException,
+ AssertionException,
ErrorCodes::CannotBuildIndexKeys);
}
@@ -277,7 +277,7 @@ TEST(FTSIndexFormat, GetKeysWithLeadingSingleElementArrayThrows) {
BSONObjSet keys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
BSONObj objToIndex = fromjson("{a: [{b: 9}], data: 'foo'}");
ASSERT_THROWS_CODE(FTSIndexFormat::getKeys(spec, objToIndex, &keys),
- UserException,
+ AssertionException,
ErrorCodes::CannotBuildIndexKeys);
}
@@ -287,7 +287,7 @@ TEST(FTSIndexFormat, GetKeysWithTrailingSingleElementArrayThrows) {
BSONObjSet keys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
BSONObj objToIndex = fromjson("{a: [{b: 9}], data: 'foo'}");
ASSERT_THROWS_CODE(FTSIndexFormat::getKeys(spec, objToIndex, &keys),
- UserException,
+ AssertionException,
ErrorCodes::CannotBuildIndexKeys);
}
@@ -297,7 +297,7 @@ TEST(FTSIndexFormat, GetKeysWithMultiElementArrayThrows) {
BSONObjSet keys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
BSONObj objToIndex = fromjson("{a: [{b: 9, c: 'foo'}, {b: 10, c: 'bar'}]}");
ASSERT_THROWS_CODE(FTSIndexFormat::getKeys(spec, objToIndex, &keys),
- UserException,
+ AssertionException,
ErrorCodes::CannotBuildIndexKeys);
}
diff --git a/src/mongo/db/fts/fts_spec_test.cpp b/src/mongo/db/fts/fts_spec_test.cpp
index ca50a0d7511..dd920d31ec1 100644
--- a/src/mongo/db/fts/fts_spec_test.cpp
+++ b/src/mongo/db/fts/fts_spec_test.cpp
@@ -55,7 +55,7 @@ void assertFixSuccess(const std::string& s) {
// fixSpec() on an already-fixed spec shouldn't change it.
BSONObj fixed2 = assertGet(FTSSpec::fixSpec(fixed));
ASSERT_BSONOBJ_EQ(fixed, fixed2);
- } catch (UserException&) {
+ } catch (AssertionException&) {
ASSERT(false);
}
}
diff --git a/src/mongo/db/geo/hash_test.cpp b/src/mongo/db/geo/hash_test.cpp
index 23aed0a6d93..8a355d095d4 100644
--- a/src/mongo/db/geo/hash_test.cpp
+++ b/src/mongo/db/geo/hash_test.cpp
@@ -121,12 +121,12 @@ static GeoHash makeHash(const string& a) {
TEST(GeoHash, MakeTooLongHash) {
string a = makeRandomBitString(100);
- ASSERT_THROWS(makeHash(a), mongo::UserException);
+ ASSERT_THROWS(makeHash(a), mongo::AssertionException);
}
TEST(GeoHash, MakeOddHash) {
string a = makeRandomBitString(13);
- ASSERT_THROWS(makeHash(a), mongo::UserException);
+ ASSERT_THROWS(makeHash(a), mongo::AssertionException);
}
TEST(GeoHash, UnhashFastMatchesUnhashSlow) {
diff --git a/src/mongo/db/index/btree_key_generator_test.cpp b/src/mongo/db/index/btree_key_generator_test.cpp
index a884b5ce619..27336b80c02 100644
--- a/src/mongo/db/index/btree_key_generator_test.cpp
+++ b/src/mongo/db/index/btree_key_generator_test.cpp
@@ -248,7 +248,7 @@ TEST(BtreeKeyGeneratorTest, GetKeysFromParallelArraysBasic) {
BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths expectedMultikeyPaths(keyPattern.nFields());
ASSERT_THROWS(testKeygen(keyPattern, genKeysFrom, expectedKeys, expectedMultikeyPaths),
- UserException);
+ AssertionException);
}
TEST(BtreeKeyGeneratorTest, GetKeysFromArraySubobjectBasic) {
@@ -356,7 +356,7 @@ TEST(BtreeKeyGeneratorTest, GetKeysFromParallelArraysComplex) {
BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths expectedMultikeyPaths(keyPattern.nFields());
ASSERT_THROWS(testKeygen(keyPattern, genKeysFrom, expectedKeys, expectedMultikeyPaths),
- UserException);
+ AssertionException);
}
TEST(BtreeKeyGeneratorTest, GetKeysAlternateMissing) {
@@ -604,11 +604,11 @@ TEST(BtreeKeyGeneratorTest, GetKeysFromIndexedArrayIndex) {
genKeysFrom = fromjson("{a:[{'0':1}]}");
expectedKeys.clear();
ASSERT_THROWS(testKeygen(keyPattern, genKeysFrom, expectedKeys, expectedMultikeyPaths),
- UserException);
+ AssertionException);
genKeysFrom = fromjson("{a:[1,{'0':2}]}");
ASSERT_THROWS(testKeygen(keyPattern, genKeysFrom, expectedKeys, expectedMultikeyPaths),
- UserException);
+ AssertionException);
}
TEST(BtreeKeyGeneratorTest, GetKeysFromDoubleIndexedArrayIndex) {
@@ -739,7 +739,7 @@ TEST(BtreeKeyGeneratorTest, ParallelArraysInNestedObjects) {
BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths expectedMultikeyPaths(keyPattern.nFields());
ASSERT_THROWS(testKeygen(keyPattern, genKeysFrom, expectedKeys, expectedMultikeyPaths),
- UserException);
+ AssertionException);
}
TEST(BtreeKeyGeneratorTest, ParallelArraysUneven) {
@@ -748,7 +748,7 @@ TEST(BtreeKeyGeneratorTest, ParallelArraysUneven) {
BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths expectedMultikeyPaths(keyPattern.nFields());
ASSERT_THROWS(testKeygen(keyPattern, genKeysFrom, expectedKeys, expectedMultikeyPaths),
- UserException);
+ AssertionException);
}
TEST(BtreeKeyGeneratorTest, MultipleArraysNotParallel) {
@@ -804,7 +804,7 @@ TEST(BtreeKeyGeneratorTest, GetKeysParallelEmptyArrays) {
BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths expectedMultikeyPaths(keyPattern.nFields());
ASSERT_THROWS(testKeygen(keyPattern, genKeysFrom, expectedKeys, expectedMultikeyPaths),
- UserException);
+ AssertionException);
}
TEST(BtreeKeyGeneratorTest, GetKeysParallelArraysOneArrayEmpty) {
@@ -813,7 +813,7 @@ TEST(BtreeKeyGeneratorTest, GetKeysParallelArraysOneArrayEmpty) {
BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths expectedMultikeyPaths(keyPattern.nFields());
ASSERT_THROWS(testKeygen(keyPattern, genKeysFrom, expectedKeys, expectedMultikeyPaths),
- UserException);
+ AssertionException);
}
TEST(BtreeKeyGeneratorTest, GetKeysParallelArraysOneArrayEmptyNested) {
@@ -822,7 +822,7 @@ TEST(BtreeKeyGeneratorTest, GetKeysParallelArraysOneArrayEmptyNested) {
BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths expectedMultikeyPaths(keyPattern.nFields());
ASSERT_THROWS(testKeygen(keyPattern, genKeysFrom, expectedKeys, expectedMultikeyPaths),
- UserException);
+ AssertionException);
}
// Descriptive test. The semantics for key generation are odd for positional key patterns.
@@ -973,7 +973,7 @@ TEST(BtreeKeyGeneratorTest, PositionalKeyPatternParallelArrays) {
BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths expectedMultikeyPaths(keyPattern.nFields());
ASSERT_THROWS(testKeygen(keyPattern, genKeysFrom, expectedKeys, expectedMultikeyPaths),
- UserException);
+ AssertionException);
}
TEST(BtreeKeyGeneratorTest, KeyPattern_a_0_b_Extracts_b_ElementInsideSingleton2DArray) {
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp
index f8cf15245be..470b5210d57 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -602,7 +602,7 @@ void IndexAccessMethod::getKeys(const BSONObj& obj,
13027};
try {
doGetKeys(obj, keys, multikeyPaths);
- } catch (const UserException& ex) {
+ } catch (const AssertionException& ex) {
if (mode == GetKeysMode::kEnforceConstraints) {
throw;
}
diff --git a/src/mongo/db/index/sort_key_generator.cpp b/src/mongo/db/index/sort_key_generator.cpp
index c636e0a1f23..e02fff9111b 100644
--- a/src/mongo/db/index/sort_key_generator.cpp
+++ b/src/mongo/db/index/sort_key_generator.cpp
@@ -149,7 +149,7 @@ StatusWith<BSONObj> SortKeyGenerator::getIndexKey(const BSONObj& obj) const {
// multikey when getting the index keys for sorting.
MultikeyPaths* multikeyPaths = nullptr;
_indexKeyGen->getKeys(obj, &keys, multikeyPaths);
- } catch (const UserException& e) {
+ } catch (const AssertionException& e) {
// Probably a parallel array.
if (ErrorCodes::CannotIndexParallelArrays == e.code()) {
return Status(ErrorCodes::BadValue, "cannot sort with keys that are parallel arrays");
diff --git a/src/mongo/db/keypattern_test.cpp b/src/mongo/db/keypattern_test.cpp
index b2d35b5aac4..eb86a529000 100644
--- a/src/mongo/db/keypattern_test.cpp
+++ b/src/mongo/db/keypattern_test.cpp
@@ -40,17 +40,17 @@ TEST(KeyPattern, ExtendRangeBound) {
// test keyPattern shorter than bound, should fail
{
KeyPattern keyPat(BSON("a" << 1));
- ASSERT_THROWS(keyPat.extendRangeBound(longBound, false), MsgAssertionException);
+ ASSERT_THROWS(keyPat.extendRangeBound(longBound, false), AssertionException);
}
// test keyPattern doesn't match bound, should fail
{
KeyPattern keyPat(BSON("b" << 1));
- ASSERT_THROWS(keyPat.extendRangeBound(bound, false), MsgAssertionException);
+ ASSERT_THROWS(keyPat.extendRangeBound(bound, false), AssertionException);
}
{
KeyPattern keyPat(BSON("a" << 1 << "c" << 1));
- ASSERT_THROWS(keyPat.extendRangeBound(longBound, false), MsgAssertionException);
+ ASSERT_THROWS(keyPat.extendRangeBound(longBound, false), AssertionException);
}
// test keyPattern same as bound
diff --git a/src/mongo/db/logical_session_id_test.cpp b/src/mongo/db/logical_session_id_test.cpp
index 410292ef801..48b25dc4148 100644
--- a/src/mongo/db/logical_session_id_test.cpp
+++ b/src/mongo/db/logical_session_id_test.cpp
@@ -139,7 +139,7 @@ TEST_F(LogicalSessionIdTest, ConstructorFromClientWithoutPassedUidAndWithoutAuth
LogicalSessionFromClient req;
req.setId(id);
- ASSERT_THROWS(makeLogicalSessionId(req, _opCtx.get()), UserException);
+ ASSERT_THROWS(makeLogicalSessionId(req, _opCtx.get()), AssertionException);
}
TEST_F(LogicalSessionIdTest, ConstructorFromClientWithPassedUidWithPermissions) {
@@ -165,7 +165,7 @@ TEST_F(LogicalSessionIdTest, ConstructorFromClientWithPassedUidWithoutAuthedUser
req.setId(id);
req.setUid(uid);
- ASSERT_THROWS(makeLogicalSessionId(req, _opCtx.get()), UserException);
+ ASSERT_THROWS(makeLogicalSessionId(req, _opCtx.get()), AssertionException);
}
TEST_F(LogicalSessionIdTest, ConstructorFromClientWithPassedUidWithoutPermissions) {
@@ -177,7 +177,7 @@ TEST_F(LogicalSessionIdTest, ConstructorFromClientWithPassedUidWithoutPermission
req.setId(id);
req.setUid(uid);
- ASSERT_THROWS(makeLogicalSessionId(req, _opCtx.get()), UserException);
+ ASSERT_THROWS(makeLogicalSessionId(req, _opCtx.get()), AssertionException);
}
TEST_F(LogicalSessionIdTest, GenWithUser) {
@@ -191,11 +191,11 @@ TEST_F(LogicalSessionIdTest, GenWithMultipleAuthedUsers) {
addSimpleUser(UserName("simple", "test"));
addSimpleUser(UserName("simple", "test2"));
- ASSERT_THROWS(makeLogicalSessionId(_opCtx.get()), UserException);
+ ASSERT_THROWS(makeLogicalSessionId(_opCtx.get()), AssertionException);
}
TEST_F(LogicalSessionIdTest, GenWithoutAuthedUser) {
- ASSERT_THROWS(makeLogicalSessionId(_opCtx.get()), UserException);
+ ASSERT_THROWS(makeLogicalSessionId(_opCtx.get()), AssertionException);
}
TEST_F(LogicalSessionIdTest, InitializeOperationSessionInfo_NoSessionIdNoTransactionNumber) {
@@ -229,7 +229,7 @@ TEST_F(LogicalSessionIdTest, InitializeOperationSessionInfo_MissingSessionIdWith
BSON("TestCmd" << 1 << "txnNumber" << 100LL << "OtherField"
<< "TestField"),
true),
- UserException,
+ AssertionException,
ErrorCodes::IllegalOperation);
}
diff --git a/src/mongo/db/matcher/copyable_match_expression.h b/src/mongo/db/matcher/copyable_match_expression.h
index f08bf2dc202..9f17fd1b082 100644
--- a/src/mongo/db/matcher/copyable_match_expression.h
+++ b/src/mongo/db/matcher/copyable_match_expression.h
@@ -46,8 +46,8 @@ namespace mongo {
class CopyableMatchExpression {
public:
/**
- * Parse 'matchAST' to create a new MatchExpression, throwing a UserException if we encounter an
- * error.
+ * Parse 'matchAST' to create a new MatchExpression, throwing a AssertionException if we
+ * encounter an error.
*/
CopyableMatchExpression(BSONObj matchAST,
std::unique_ptr<const ExtensionsCallback> extensionsCallback,
diff --git a/src/mongo/db/matcher/expression_parser_geo_test.cpp b/src/mongo/db/matcher/expression_parser_geo_test.cpp
index 4e4197a422d..c7e82af29ab 100644
--- a/src/mongo/db/matcher/expression_parser_geo_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_geo_test.cpp
@@ -94,7 +94,7 @@ TEST(MatchExpressionParserGeoNear, ParseNearExtraField) {
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator)
.status_with_transitional_ignore(),
- UserException);
+ AssertionException);
}
// For $near, $nearSphere, and $geoNear syntax of:
@@ -140,7 +140,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidNear) {
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator)
.status_with_transitional_ignore(),
- UserException);
+ AssertionException);
}
{
BSONObj query = fromjson("{loc: {$near: [0,0], $minDistance: {}}}");
@@ -148,7 +148,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidNear) {
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator)
.status_with_transitional_ignore(),
- UserException);
+ AssertionException);
}
{
BSONObj query = fromjson("{loc: {$near: [0,0], $eq: 40}}");
@@ -156,7 +156,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidNear) {
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator)
.status_with_transitional_ignore(),
- UserException);
+ AssertionException);
}
{
BSONObj query = fromjson("{loc: {$eq: 40, $near: [0,0]}}");
@@ -172,7 +172,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidNear) {
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator)
.status_with_transitional_ignore(),
- UserException);
+ AssertionException);
}
{
BSONObj query = fromjson("{loc: {$near: {$foo: 1}}}");
@@ -227,7 +227,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidGeoNear) {
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator)
.status_with_transitional_ignore(),
- UserException);
+ AssertionException);
}
{
BSONObj query = fromjson("{loc: {$geoNear: [0,0], $maxDistance: {}}}");
@@ -235,7 +235,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidGeoNear) {
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator)
.status_with_transitional_ignore(),
- UserException);
+ AssertionException);
}
{
BSONObj query = fromjson("{loc: {$geoNear: [0,0], $minDistance: {}}}");
@@ -243,7 +243,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidGeoNear) {
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator)
.status_with_transitional_ignore(),
- UserException);
+ AssertionException);
}
}
@@ -284,7 +284,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidNearSphere) {
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator)
.status_with_transitional_ignore(),
- UserException);
+ AssertionException);
}
{
BSONObj query = fromjson("{loc: {$nearSphere: [0,0], $minDistance: {}}}");
@@ -292,7 +292,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidNearSphere) {
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator)
.status_with_transitional_ignore(),
- UserException);
+ AssertionException);
}
{
BSONObj query = fromjson("{loc: {$nearSphere: [0,0], $eq: 1}}");
@@ -300,7 +300,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidNearSphere) {
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator)
.status_with_transitional_ignore(),
- UserException);
+ AssertionException);
}
}
diff --git a/src/mongo/db/matcher/expression_parser_leaf_test.cpp b/src/mongo/db/matcher/expression_parser_leaf_test.cpp
index 90b4c80dfc4..7181c8dea59 100644
--- a/src/mongo/db/matcher/expression_parser_leaf_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_leaf_test.cpp
@@ -103,7 +103,7 @@ TEST(MatchExpressionParserLeafTest, ConstantExprFailsWithMissingVariable) {
ASSERT_THROWS_CODE(auto sw = MatchExpressionParser::parse(
query, ExtensionsCallbackDisallowExtensions(), collator, expCtx),
- UserException,
+ AssertionException,
17276);
}
diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h
index 68641488d48..6b2e28be20d 100644
--- a/src/mongo/db/operation_context.h
+++ b/src/mongo/db/operation_context.h
@@ -137,7 +137,7 @@ public:
std::unique_ptr<Locker> releaseLockState();
/**
- * Raises a UserException if this operation is in a killed state.
+ * Raises a AssertionException if this operation is in a killed state.
*/
void checkForInterrupt();
@@ -159,7 +159,7 @@ public:
/**
* Waits for either the condition "cv" to be signaled, this operation to be interrupted, or the
* deadline on this operation to expire. In the event of interruption or operation deadline
- * expiration, raises a UserException with an error code indicating the interruption type.
+ * expiration, raises a AssertionException with an error code indicating the interruption type.
*/
void waitForConditionOrInterrupt(stdx::condition_variable& cv,
stdx::unique_lock<stdx::mutex>& m);
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp
index 674180acc69..3108743f97c 100644
--- a/src/mongo/db/ops/write_ops_exec.cpp
+++ b/src/mongo/db/ops/write_ops_exec.cpp
@@ -209,10 +209,10 @@ bool handleError(OperationContext* opCtx,
auto staleConfigException = dynamic_cast<const SendStaleConfigException*>(&ex);
if (!staleConfigException) {
// We need to get extra info off of the SCE, but some common patterns can result in the
- // exception being converted to a Status then rethrown as a UserException, losing the
- // info we need. It would be a bug if this happens so we want to detect it in testing,
- // but it isn't severe enough that we should bring down the server if it happens in
- // production.
+ // exception being converted to a Status then rethrown as a AssertionException, losing
+ // the info we need. It would be a bug if this happens so we want to detect it in
+ // testing, but it isn't severe enough that we should bring down the server if it
+ // happens in production.
dassert(staleConfigException);
msgassertedNoTrace(35475,
str::stream()
@@ -485,7 +485,7 @@ WriteResult performInserts(OperationContext* opCtx, const write_ops::Insert& who
globalOpCounters.gotInsert();
canContinue = handleError(
opCtx,
- UserException(fixedDoc.getStatus().code(), fixedDoc.getStatus().reason()),
+ AssertionException(fixedDoc.getStatus().code(), fixedDoc.getStatus().reason()),
wholeOp.getNamespace(),
wholeOp.getWriteCommandBase(),
&out);
diff --git a/src/mongo/db/ops/write_ops_parsers_test.cpp b/src/mongo/db/ops/write_ops_parsers_test.cpp
index 0f461e9a28e..3e5ba9e7906 100644
--- a/src/mongo/db/ops/write_ops_parsers_test.cpp
+++ b/src/mongo/db/ops/write_ops_parsers_test.cpp
@@ -98,7 +98,7 @@ TEST(CommandWriteOpsParsers, GarbageFieldsAtTopLevel_Body) {
<< BSON_ARRAY(BSONObj()));
for (bool seq : {false, true}) {
auto request = toOpMsg("foo", cmd, seq);
- ASSERT_THROWS(InsertOp::parse(request), UserException);
+ ASSERT_THROWS(InsertOp::parse(request), AssertionException);
}
}
@@ -111,7 +111,7 @@ TEST(CommandWriteOpsParsers, ErrorOnDuplicateCommonField) {
<< BSON_ARRAY(BSONObj()));
for (bool seq : {false, true}) {
auto request = toOpMsg("foo", cmd, seq);
- ASSERT_THROWS(InsertOp::parse(request), UserException);
+ ASSERT_THROWS(InsertOp::parse(request), AssertionException);
}
}
@@ -128,7 +128,7 @@ TEST(CommandWriteOpsParsers, ErrorOnDuplicateCommonFieldBetweenBodyAndSequence)
BSONObj(),
}}};
- ASSERT_THROWS(InsertOp::parse(request), UserException);
+ ASSERT_THROWS(InsertOp::parse(request), AssertionException);
}
TEST(CommandWriteOpsParsers, GarbageFieldsInUpdateDoc) {
@@ -138,7 +138,7 @@ TEST(CommandWriteOpsParsers, GarbageFieldsInUpdateDoc) {
<< BSON_ARRAY(BSON("q" << BSONObj() << "u" << BSONObj() << "GARBAGE" << 1)));
for (bool seq : {false, true}) {
auto request = toOpMsg("foo", cmd, seq);
- ASSERT_THROWS(UpdateOp::parse(request), UserException);
+ ASSERT_THROWS(UpdateOp::parse(request), AssertionException);
}
}
@@ -149,7 +149,7 @@ TEST(CommandWriteOpsParsers, GarbageFieldsInDeleteDoc) {
<< BSON_ARRAY(BSON("q" << BSONObj() << "limit" << 0 << "GARBAGE" << 1)));
for (bool seq : {false, true}) {
auto request = toOpMsg("foo", cmd, seq);
- ASSERT_THROWS(DeleteOp::parse(request), UserException);
+ ASSERT_THROWS(DeleteOp::parse(request), AssertionException);
}
}
@@ -160,7 +160,7 @@ TEST(CommandWriteOpsParsers, BadCollationFieldInUpdateDoc) {
<< BSON_ARRAY(BSON("q" << BSONObj() << "u" << BSONObj() << "collation" << 1)));
for (bool seq : {false, true}) {
auto request = toOpMsg("foo", cmd, seq);
- ASSERT_THROWS_CODE(UpdateOp::parse(request), UserException, ErrorCodes::TypeMismatch);
+ ASSERT_THROWS_CODE(UpdateOp::parse(request), AssertionException, ErrorCodes::TypeMismatch);
}
}
@@ -171,7 +171,7 @@ TEST(CommandWriteOpsParsers, BadCollationFieldInDeleteDoc) {
<< BSON_ARRAY(BSON("q" << BSONObj() << "limit" << 0 << "collation" << 1)));
for (bool seq : {false, true}) {
auto request = toOpMsg("foo", cmd, seq);
- ASSERT_THROWS_CODE(DeleteOp::parse(request), UserException, ErrorCodes::TypeMismatch);
+ ASSERT_THROWS_CODE(DeleteOp::parse(request), AssertionException, ErrorCodes::TypeMismatch);
}
}
@@ -183,7 +183,7 @@ TEST(CommandWriteOpsParsers, BadArrayFiltersFieldInUpdateDoc) {
<< "bad")));
for (bool seq : {false, true}) {
auto request = toOpMsg("foo", cmd, seq);
- ASSERT_THROWS(UpdateOp::parse(request), UserException);
+ ASSERT_THROWS(UpdateOp::parse(request), AssertionException);
}
}
@@ -195,7 +195,7 @@ TEST(CommandWriteOpsParsers, BadArrayFiltersElementInUpdateDoc) {
<< BSON_ARRAY("bad"))));
for (bool seq : {false, true}) {
auto request = toOpMsg("foo", cmd, seq);
- ASSERT_THROWS_CODE(UpdateOp::parse(request), UserException, ErrorCodes::TypeMismatch);
+ ASSERT_THROWS_CODE(UpdateOp::parse(request), AssertionException, ErrorCodes::TypeMismatch);
}
}
@@ -219,7 +219,7 @@ TEST(CommandWriteOpsParsers, EmptyMultiInsertFails) {
auto cmd = BSON("insert" << ns.coll() << "documents" << BSONArray());
for (bool seq : {false, true}) {
auto request = toOpMsg(ns.db(), cmd, seq);
- ASSERT_THROWS_CODE(InsertOp::parse(request), UserException, ErrorCodes::InvalidLength);
+ ASSERT_THROWS_CODE(InsertOp::parse(request), AssertionException, ErrorCodes::InvalidLength);
}
}
@@ -312,7 +312,8 @@ TEST(CommandWriteOpsParsers, RemoveErrorsWithBadLimit) {
<< BSON_ARRAY(BSON("q" << BSONObj() << "limit" << limit)));
for (bool seq : {false, true}) {
auto request = toOpMsg("foo", cmd, seq);
- ASSERT_THROWS_CODE(DeleteOp::parse(request), UserException, ErrorCodes::FailedToParse);
+ ASSERT_THROWS_CODE(
+ DeleteOp::parse(request), AssertionException, ErrorCodes::FailedToParse);
}
}
}
@@ -339,7 +340,7 @@ TEST(LegacyWriteOpsParsers, EmptyMultiInsertFails) {
auto message = makeInsertMessage(
ns, objs.data(), objs.size(), (continueOnError ? InsertOption_ContinueOnError : 0));
ASSERT_THROWS_CODE(
- InsertOp::parseLegacy(message), UserException, ErrorCodes::InvalidLength);
+ InsertOp::parseLegacy(message), AssertionException, ErrorCodes::InvalidLength);
}
}
diff --git a/src/mongo/db/pipeline/accumulation_statement.h b/src/mongo/db/pipeline/accumulation_statement.h
index 91a58e3a8e2..d722938032f 100644
--- a/src/mongo/db/pipeline/accumulation_statement.h
+++ b/src/mongo/db/pipeline/accumulation_statement.h
@@ -68,7 +68,7 @@ public:
* Parses a BSONElement that is an accumulated field, and returns an AccumulationStatement for
* that accumulated field.
*
- * Throws a UserException if parsing fails.
+ * Throws a AssertionException if parsing fails.
*/
static AccumulationStatement parseAccumulationStatement(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
diff --git a/src/mongo/db/pipeline/aggregation_request_test.cpp b/src/mongo/db/pipeline/aggregation_request_test.cpp
index 5b5540357c7..8192e0fed3e 100644
--- a/src/mongo/db/pipeline/aggregation_request_test.cpp
+++ b/src/mongo/db/pipeline/aggregation_request_test.cpp
@@ -404,25 +404,27 @@ TEST(AggregationRequestTest, ParseNSShouldReturnAggregateOneNSIfAggregateFieldIs
TEST(AggregationRequestTest, ParseNSShouldRejectNumericNSIfAggregateFieldIsNotOne) {
const BSONObj inputBSON = fromjson("{aggregate: 2, pipeline: []}");
ASSERT_THROWS_CODE(
- AggregationRequest::parseNs("a", inputBSON), UserException, ErrorCodes::FailedToParse);
+ AggregationRequest::parseNs("a", inputBSON), AssertionException, ErrorCodes::FailedToParse);
}
TEST(AggregationRequestTest, ParseNSShouldRejectNonStringNonNumericNS) {
const BSONObj inputBSON = fromjson("{aggregate: {}, pipeline: []}");
ASSERT_THROWS_CODE(
- AggregationRequest::parseNs("a", inputBSON), UserException, ErrorCodes::TypeMismatch);
+ AggregationRequest::parseNs("a", inputBSON), AssertionException, ErrorCodes::TypeMismatch);
}
TEST(AggregationRequestTest, ParseNSShouldRejectAggregateOneStringAsCollectionName) {
const BSONObj inputBSON = fromjson("{aggregate: '$cmd.aggregate', pipeline: []}");
- ASSERT_THROWS_CODE(
- AggregationRequest::parseNs("a", inputBSON), UserException, ErrorCodes::InvalidNamespace);
+ ASSERT_THROWS_CODE(AggregationRequest::parseNs("a", inputBSON),
+ AssertionException,
+ ErrorCodes::InvalidNamespace);
}
TEST(AggregationRequestTest, ParseNSShouldRejectInvalidCollectionName) {
const BSONObj inputBSON = fromjson("{aggregate: '', pipeline: []}");
- ASSERT_THROWS_CODE(
- AggregationRequest::parseNs("a", inputBSON), UserException, ErrorCodes::InvalidNamespace);
+ ASSERT_THROWS_CODE(AggregationRequest::parseNs("a", inputBSON),
+ AssertionException,
+ ErrorCodes::InvalidNamespace);
}
TEST(AggregationRequestTest, ParseFromBSONOverloadsShouldProduceIdenticalRequests) {
diff --git a/src/mongo/db/pipeline/document.h b/src/mongo/db/pipeline/document.h
index e004f7ab982..5e5980f5a51 100644
--- a/src/mongo/db/pipeline/document.h
+++ b/src/mongo/db/pipeline/document.h
@@ -192,7 +192,8 @@ public:
/**
* Serializes this document to the BSONObj under construction in 'builder'. Metadata is not
- * included. Throws a UserException if 'recursionLevel' exceeds the maximum allowable depth.
+ * included. Throws a AssertionException if 'recursionLevel' exceeds the maximum allowable
+ * depth.
*/
void toBson(BSONObjBuilder* builder, size_t recursionLevel = 1) const;
BSONObj toBson() const;
diff --git a/src/mongo/db/pipeline/document_source_add_fields_test.cpp b/src/mongo/db/pipeline/document_source_add_fields_test.cpp
index a11b894e542..fa9b27f5d61 100644
--- a/src/mongo/db/pipeline/document_source_add_fields_test.cpp
+++ b/src/mongo/db/pipeline/document_source_add_fields_test.cpp
@@ -86,8 +86,9 @@ TEST_F(AddFieldsTest, ShouldErrorOnNonObjectSpec) {
BSONObj spec = BSON("$addFields"
<< "foo");
BSONElement specElement = spec.firstElement();
- ASSERT_THROWS_CODE(
- DocumentSourceAddFields::createFromBson(specElement, getExpCtx()), UserException, 40272);
+ ASSERT_THROWS_CODE(DocumentSourceAddFields::createFromBson(specElement, getExpCtx()),
+ AssertionException,
+ 40272);
}
TEST_F(AddFieldsTest, ShouldBeAbleToProcessMultipleDocuments) {
@@ -223,7 +224,7 @@ TEST_F(AddFieldsTest, CannotAddNestedDocumentExceedingDepthLimit) {
ASSERT_THROWS_CODE(
DocumentSourceAddFields::create(
makeAddFieldsForNestedDocument(BSONDepth::getMaxAllowableDepth() + 1), getExpCtx()),
- UserException,
+ AssertionException,
ErrorCodes::Overflow);
}
} // namespace
diff --git a/src/mongo/db/pipeline/document_source_bucket_auto_test.cpp b/src/mongo/db/pipeline/document_source_bucket_auto_test.cpp
index 7afa30e1c8b..333a130a0ae 100644
--- a/src/mongo/db/pipeline/document_source_bucket_auto_test.cpp
+++ b/src/mongo/db/pipeline/document_source_bucket_auto_test.cpp
@@ -527,103 +527,103 @@ TEST_F(BucketAutoTests, ShouldBeAbleToReParseSerializedStage) {
TEST_F(BucketAutoTests, FailsWithInvalidNumberOfBuckets) {
auto spec = fromjson("{$bucketAuto : {groupBy : '$x', buckets : 'test'}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40241);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40241);
spec = fromjson("{$bucketAuto : {groupBy : '$x', buckets : 2147483648}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40242);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40242);
spec = fromjson("{$bucketAuto : {groupBy : '$x', buckets : 1.5}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40242);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40242);
spec = fromjson("{$bucketAuto : {groupBy : '$x', buckets : 0}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40243);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40243);
spec = fromjson("{$bucketAuto : {groupBy : '$x', buckets : -1}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40243);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40243);
// Use the create() helper.
const int numBuckets = 0;
ASSERT_THROWS_CODE(
DocumentSourceBucketAuto::create(
getExpCtx(), ExpressionConstant::create(getExpCtx(), Value(0)), numBuckets),
- UserException,
+ AssertionException,
40243);
}
TEST_F(BucketAutoTests, FailsWithNonExpressionGroupBy) {
auto spec = fromjson("{$bucketAuto : {groupBy : 'test', buckets : 1}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40239);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40239);
spec = fromjson("{$bucketAuto : {groupBy : {test : 'test'}, buckets : 1}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40239);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40239);
}
TEST_F(BucketAutoTests, FailsWithNonObjectArgument) {
auto spec = fromjson("{$bucketAuto : 'test'}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40240);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40240);
spec = fromjson("{$bucketAuto : [1, 2, 3]}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40240);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40240);
}
TEST_F(BucketAutoTests, FailsWithNonObjectOutput) {
auto spec = fromjson("{$bucketAuto : {groupBy : '$x', buckets : 1, output : 'test'}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40244);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40244);
spec = fromjson("{$bucketAuto : {groupBy : '$x', buckets : 1, output : [1, 2, 3]}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40244);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40244);
spec = fromjson("{$bucketAuto : {groupBy : '$x', buckets : 1, output : 1}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40244);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40244);
}
TEST_F(BucketAutoTests, FailsWhenGroupByMissing) {
auto spec = fromjson("{$bucketAuto : {buckets : 1}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40246);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40246);
}
TEST_F(BucketAutoTests, FailsWhenBucketsMissing) {
auto spec = fromjson("{$bucketAuto : {groupBy : '$x'}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40246);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40246);
}
TEST_F(BucketAutoTests, FailsWithUnknownField) {
auto spec = fromjson("{$bucketAuto : {groupBy : '$x', buckets : 1, field : 'test'}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40245);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40245);
}
TEST_F(BucketAutoTests, FailsWithInvalidExpressionToAccumulator) {
auto spec = fromjson(
"{$bucketAuto : {groupBy : '$x', buckets : 1, output : {avg : {$avg : ['$x', 1]}}}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40237);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40237);
spec = fromjson(
"{$bucketAuto : {groupBy : '$x', buckets : 1, output : {test : {$avg : '$x', $sum : "
"'$x'}}}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40238);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40238);
}
TEST_F(BucketAutoTests, FailsWithNonAccumulatorObjectOutputField) {
auto spec =
fromjson("{$bucketAuto : {groupBy : '$x', buckets : 1, output : {field : 'test'}}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40234);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40234);
spec = fromjson("{$bucketAuto : {groupBy : '$x', buckets : 1, output : {field : 1}}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40234);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40234);
spec = fromjson(
"{$bucketAuto : {groupBy : '$x', buckets : 1, output : {test : {field : 'test'}}}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40234);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40234);
}
TEST_F(BucketAutoTests, FailsWithInvalidOutputFieldName) {
auto spec = fromjson(
"{$bucketAuto : {groupBy : '$x', buckets : 1, output : {'field.test' : {$avg : '$x'}}}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40235);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40235);
spec = fromjson(
"{$bucketAuto : {groupBy : '$x', buckets : 1, output : {'$field' : {$avg : '$x'}}}}");
- ASSERT_THROWS_CODE(createBucketAuto(spec), UserException, 40236);
+ ASSERT_THROWS_CODE(createBucketAuto(spec), AssertionException, 40236);
}
void assertCannotSpillToDisk(const boost::intrusive_ptr<ExpressionContext>& expCtx) {
@@ -641,7 +641,7 @@ void assertCannotSpillToDisk(const boost::intrusive_ptr<ExpressionContext>& expC
{Document{{"a", 0}, {"largeStr", largeStr}}, Document{{"a", 1}, {"largeStr", largeStr}}});
bucketAutoStage->setSource(mock.get());
- ASSERT_THROWS_CODE(bucketAutoStage->getNext(), UserException, 16819);
+ ASSERT_THROWS_CODE(bucketAutoStage->getNext(), AssertionException, 16819);
}
TEST_F(BucketAutoTests, ShouldFailIfBufferingTooManyDocuments) {
@@ -683,7 +683,7 @@ TEST_F(BucketAutoTests, ShouldCorrectlyTrackMemoryUsageBetweenPauses) {
ASSERT_TRUE(bucketAutoStage->getNext().isPaused());
// The next should realize it's used too much memory.
- ASSERT_THROWS_CODE(bucketAutoStage->getNext(), UserException, 16819);
+ ASSERT_THROWS_CODE(bucketAutoStage->getNext(), AssertionException, 16819);
}
TEST_F(BucketAutoTests, ShouldRoundUpMaximumBoundariesWithGranularitySpecified) {
@@ -774,7 +774,7 @@ TEST_F(BucketAutoTests, ShouldFailOnNaNWhenGranularitySpecified) {
Document{{"x", std::nan("NaN")}},
Document{{"x", 1}},
Document{{"x", 1}}}),
- UserException,
+ AssertionException,
40259);
}
@@ -787,7 +787,7 @@ TEST_F(BucketAutoTests, ShouldFailOnNonNumericValuesWhenGranularitySpecified) {
Document{{"x", "test"_sd}},
Document{{"x", 1}},
Document{{"x", 1}}}),
- UserException,
+ AssertionException,
40258);
}
@@ -799,7 +799,7 @@ TEST_F(BucketAutoTests, ShouldFailOnNegativeNumbersWhenGranularitySpecified) {
getResults(
bucketAutoSpec,
{Document{{"x", 0}}, Document{{"x", -1}}, Document{{"x", 1}}, Document{{"x", 2}}}),
- UserException,
+ AssertionException,
40260);
}
} // namespace
diff --git a/src/mongo/db/pipeline/document_source_bucket_test.cpp b/src/mongo/db/pipeline/document_source_bucket_test.cpp
index 26f18c4dca9..fc7704d6a8d 100644
--- a/src/mongo/db/pipeline/document_source_bucket_test.cpp
+++ b/src/mongo/db/pipeline/document_source_bucket_test.cpp
@@ -163,107 +163,107 @@ public:
TEST_F(InvalidBucketSpec, BucketFailsWithNonObject) {
auto spec = fromjson("{$bucket : 1}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40201);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40201);
spec = fromjson("{$bucket : 'test'}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40201);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40201);
}
TEST_F(InvalidBucketSpec, BucketFailsWithUnknownField) {
const auto spec =
fromjson("{$bucket : {groupBy : '$x', boundaries : [0, 1, 2], unknown : 'field'}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40197);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40197);
}
TEST_F(InvalidBucketSpec, BucketFailsWithNoGroupBy) {
const auto spec = fromjson("{$bucket : {boundaries : [0, 1, 2]}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40198);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40198);
}
TEST_F(InvalidBucketSpec, BucketFailsWithNoBoundaries) {
const auto spec = fromjson("{$bucket : {groupBy : '$x'}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40198);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40198);
}
TEST_F(InvalidBucketSpec, BucketFailsWithNonExpressionGroupBy) {
auto spec = fromjson("{$bucket : {groupBy : {test : 'obj'}, boundaries : [0, 1, 2]}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40202);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40202);
spec = fromjson("{$bucket : {groupBy : 'test', boundaries : [0, 1, 2]}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40202);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40202);
spec = fromjson("{$bucket : {groupBy : 1, boundaries : [0, 1, 2]}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40202);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40202);
}
TEST_F(InvalidBucketSpec, BucketFailsWithNonArrayBoundaries) {
auto spec = fromjson("{$bucket : {groupBy : '$x', boundaries : 'test'}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40200);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40200);
spec = fromjson("{$bucket : {groupBy : '$x', boundaries : 1}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40200);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40200);
spec = fromjson("{$bucket : {groupBy : '$x', boundaries : {test : 'obj'}}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40200);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40200);
}
TEST_F(InvalidBucketSpec, BucketFailsWithNotEnoughBoundaries) {
auto spec = fromjson("{$bucket : {groupBy : '$x', boundaries : [0]}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40192);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40192);
spec = fromjson("{$bucket : {groupBy : '$x', boundaries : []}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40192);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40192);
}
TEST_F(InvalidBucketSpec, BucketFailsWithNonConstantValueBoundaries) {
const auto spec = fromjson("{$bucket : {groupBy : '$x', boundaries : ['$x', '$y', '$z']}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40191);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40191);
}
TEST_F(InvalidBucketSpec, BucketFailsWithMixedTypesBoundaries) {
const auto spec = fromjson("{$bucket : {groupBy : '$x', boundaries : [0, 'test']}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40193);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40193);
}
TEST_F(InvalidBucketSpec, BucketFailsWithNonUniqueBoundaries) {
auto spec = fromjson("{$bucket : {groupBy : '$x', boundaries : [1, 1, 2, 3]}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40194);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40194);
spec = fromjson("{$bucket : {groupBy : '$x', boundaries : ['a', 'b', 'b', 'c']}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40194);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40194);
}
TEST_F(InvalidBucketSpec, BucketFailsWithNonSortedBoundaries) {
const auto spec = fromjson("{$bucket : {groupBy : '$x', boundaries : [4, 5, 3, 6]}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40194);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40194);
}
TEST_F(InvalidBucketSpec, BucketFailsWithNonConstantExpressionDefault) {
const auto spec =
fromjson("{$bucket : {groupBy : '$x', boundaries : [0, 1, 2], default : '$x'}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40195);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40195);
}
TEST_F(InvalidBucketSpec, BucketFailsWhenDefaultIsInBoundariesRange) {
auto spec = fromjson("{$bucket : {groupBy : '$x', boundaries : [1, 2, 4], default : 3}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40199);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40199);
spec = fromjson("{$bucket : {groupBy : '$x', boundaries : [1, 2, 4], default : 1}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40199);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40199);
}
TEST_F(InvalidBucketSpec, GroupFailsForBucketWithInvalidOutputField) {
auto spec = fromjson("{$bucket : {groupBy : '$x', boundaries : [1, 2, 3], output : 'test'}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40196);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40196);
spec = fromjson(
"{$bucket : {groupBy : '$x', boundaries : [1, 2, 3], output : {number : 'test'}}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40234);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40234);
spec = fromjson(
"{$bucket : {groupBy : '$x', boundaries : [1, 2, 3], output : {'test.test' : {$sum : "
"1}}}}");
- ASSERT_THROWS_CODE(createBucket(spec), UserException, 40235);
+ ASSERT_THROWS_CODE(createBucket(spec), AssertionException, 40235);
}
TEST_F(InvalidBucketSpec, SwitchFailsForBucketWhenNoDefaultSpecified) {
@@ -281,7 +281,7 @@ TEST_F(InvalidBucketSpec, SwitchFailsForBucketWhenNoDefaultSpecified) {
auto doc = Document{{"x", 4}};
auto source = DocumentSourceMock::create(doc);
groupStage->setSource(source.get());
- ASSERT_THROWS_CODE(groupStage->getNext(), UserException, 40066);
+ ASSERT_THROWS_CODE(groupStage->getNext(), AssertionException, 40066);
}
} // namespace
} // namespace mongo
diff --git a/src/mongo/db/pipeline/document_source_change_stream_test.cpp b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
index 158de011548..4a2797349e9 100644
--- a/src/mongo/db/pipeline/document_source_change_stream_test.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
@@ -138,7 +138,7 @@ TEST_F(ChangeStreamStageTest, ShouldRejectUnrecognizedOption) {
ASSERT_THROWS_CODE(
DSChangeStream::createFromBson(
BSON(DSChangeStream::kStageName << BSON("unexpected" << 4)).firstElement(), expCtx),
- UserException,
+ AssertionException,
40415);
}
@@ -149,7 +149,7 @@ TEST_F(ChangeStreamStageTest, ShouldRejectNonStringFullDocumentOption) {
DSChangeStream::createFromBson(
BSON(DSChangeStream::kStageName << BSON("fullDocument" << true)).firstElement(),
expCtx),
- UserException,
+ AssertionException,
ErrorCodes::TypeMismatch);
}
@@ -161,7 +161,7 @@ TEST_F(ChangeStreamStageTest, ShouldRejectUnrecognizedFullDocumentOption) {
<< "unrecognized"))
.firstElement(),
expCtx),
- UserException,
+ AssertionException,
40575);
}
@@ -169,7 +169,7 @@ TEST_F(ChangeStreamStageTestNoSetup, FailsWithNoReplicationCoordinator) {
const auto spec = fromjson("{$changeStream: {}}");
ASSERT_THROWS_CODE(DocumentSourceChangeStream::createFromBson(spec.firstElement(), getExpCtx()),
- UserException,
+ AssertionException,
40573);
}
diff --git a/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp b/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp
index 5f6d73035eb..9cf2090b5cb 100644
--- a/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp
+++ b/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp
@@ -164,7 +164,7 @@ TEST_F(CheckResumeTokenTest, ShouldFailIfFirstDocHasWrongResumeToken) {
Timestamp doc2Timestamp(101, 1);
addDocument(doc1Timestamp, "1");
addDocument(doc2Timestamp, "2");
- ASSERT_THROWS_CODE(checkResumeToken->getNext(), UserException, 40585);
+ ASSERT_THROWS_CODE(checkResumeToken->getNext(), AssertionException, 40585);
}
TEST_F(CheckResumeTokenTest, ShouldFailIfTokenHasWrongDocumentId) {
@@ -172,7 +172,7 @@ TEST_F(CheckResumeTokenTest, ShouldFailIfTokenHasWrongDocumentId) {
auto checkResumeToken = createCheckResumeToken(resumeTimestamp, "0");
addDocument(resumeTimestamp, "1");
- ASSERT_THROWS_CODE(checkResumeToken->getNext(), UserException, 40585);
+ ASSERT_THROWS_CODE(checkResumeToken->getNext(), AssertionException, 40585);
}
TEST_F(CheckResumeTokenTest, ShouldFailIfTokenHasWrongNamespace) {
@@ -180,7 +180,7 @@ TEST_F(CheckResumeTokenTest, ShouldFailIfTokenHasWrongNamespace) {
auto checkResumeToken = createCheckResumeToken(resumeTimestamp, "1", "test1.ns");
addDocument(resumeTimestamp, "1", "test2.ns");
- ASSERT_THROWS_CODE(checkResumeToken->getNext(), UserException, 40585);
+ ASSERT_THROWS_CODE(checkResumeToken->getNext(), AssertionException, 40585);
}
/**
@@ -190,7 +190,7 @@ TEST_F(CheckResumeTokenTest, ShouldFailWithNoDocuments) {
Timestamp resumeTimestamp(100, 1);
auto checkResumeToken = createCheckResumeToken(resumeTimestamp, "0");
- ASSERT_THROWS_CODE(checkResumeToken->getNext(), UserException, 40584);
+ ASSERT_THROWS_CODE(checkResumeToken->getNext(), AssertionException, 40584);
}
} // namespace
diff --git a/src/mongo/db/pipeline/document_source_count_test.cpp b/src/mongo/db/pipeline/document_source_count_test.cpp
index 254f011ff1d..b0e5050e0ff 100644
--- a/src/mongo/db/pipeline/document_source_count_test.cpp
+++ b/src/mongo/db/pipeline/document_source_count_test.cpp
@@ -103,35 +103,35 @@ public:
TEST_F(InvalidCountSpec, NonStringSpec) {
BSONObj spec = BSON("$count" << 1);
- ASSERT_THROWS_CODE(createCount(spec), UserException, 40156);
+ ASSERT_THROWS_CODE(createCount(spec), AssertionException, 40156);
spec = BSON("$count" << BSON("field1"
<< "test"));
- ASSERT_THROWS_CODE(createCount(spec), UserException, 40156);
+ ASSERT_THROWS_CODE(createCount(spec), AssertionException, 40156);
}
TEST_F(InvalidCountSpec, EmptyStringSpec) {
BSONObj spec = BSON("$count"
<< "");
- ASSERT_THROWS_CODE(createCount(spec), UserException, 40157);
+ ASSERT_THROWS_CODE(createCount(spec), AssertionException, 40157);
}
TEST_F(InvalidCountSpec, FieldPathSpec) {
BSONObj spec = BSON("$count"
<< "$x");
- ASSERT_THROWS_CODE(createCount(spec), UserException, 40158);
+ ASSERT_THROWS_CODE(createCount(spec), AssertionException, 40158);
}
TEST_F(InvalidCountSpec, EmbeddedNullByteSpec) {
BSONObj spec = BSON("$count"
<< "te\0st"_sd);
- ASSERT_THROWS_CODE(createCount(spec), UserException, 40159);
+ ASSERT_THROWS_CODE(createCount(spec), AssertionException, 40159);
}
TEST_F(InvalidCountSpec, PeriodInStringSpec) {
BSONObj spec = BSON("$count"
<< "test.string");
- ASSERT_THROWS_CODE(createCount(spec), UserException, 40160);
+ ASSERT_THROWS_CODE(createCount(spec), AssertionException, 40160);
}
} // namespace
} // namespace mongo
diff --git a/src/mongo/db/pipeline/document_source_current_op_test.cpp b/src/mongo/db/pipeline/document_source_current_op_test.cpp
index 6afbc9e24dc..b852c94ffbe 100644
--- a/src/mongo/db/pipeline/document_source_current_op_test.cpp
+++ b/src/mongo/db/pipeline/document_source_current_op_test.cpp
@@ -86,7 +86,7 @@ private:
TEST_F(DocumentSourceCurrentOpTest, ShouldFailToParseIfSpecIsNotObject) {
const auto specObj = fromjson("{$currentOp:1}");
ASSERT_THROWS_CODE(DocumentSourceCurrentOp::createFromBson(specObj.firstElement(), getExpCtx()),
- UserException,
+ AssertionException,
ErrorCodes::FailedToParse);
}
@@ -94,7 +94,7 @@ TEST_F(DocumentSourceCurrentOpTest, ShouldFailToParseIfNotRunOnAdmin) {
const auto specObj = fromjson("{$currentOp:{}}");
getExpCtx()->ns = NamespaceString::makeCollectionlessAggregateNSS("foo");
ASSERT_THROWS_CODE(DocumentSourceCurrentOp::createFromBson(specObj.firstElement(), getExpCtx()),
- UserException,
+ AssertionException,
ErrorCodes::InvalidNamespace);
}
@@ -102,35 +102,35 @@ TEST_F(DocumentSourceCurrentOpTest, ShouldFailToParseIfNotRunWithAggregateOne) {
const auto specObj = fromjson("{$currentOp:{}}");
getExpCtx()->ns = NamespaceString("admin.foo");
ASSERT_THROWS_CODE(DocumentSourceCurrentOp::createFromBson(specObj.firstElement(), getExpCtx()),
- UserException,
+ AssertionException,
ErrorCodes::InvalidNamespace);
}
TEST_F(DocumentSourceCurrentOpTest, ShouldFailToParseIdleConnectionsIfNotBoolean) {
const auto specObj = fromjson("{$currentOp:{idleConnections:1}}");
ASSERT_THROWS_CODE(DocumentSourceCurrentOp::createFromBson(specObj.firstElement(), getExpCtx()),
- UserException,
+ AssertionException,
ErrorCodes::FailedToParse);
}
TEST_F(DocumentSourceCurrentOpTest, ShouldFailToParseAllUsersIfNotBoolean) {
const auto specObj = fromjson("{$currentOp:{allUsers:1}}");
ASSERT_THROWS_CODE(DocumentSourceCurrentOp::createFromBson(specObj.firstElement(), getExpCtx()),
- UserException,
+ AssertionException,
ErrorCodes::FailedToParse);
}
TEST_F(DocumentSourceCurrentOpTest, ShouldFailToParseTruncateOpsIfNotBoolean) {
const auto specObj = fromjson("{$currentOp:{truncateOps:1}}");
ASSERT_THROWS_CODE(DocumentSourceCurrentOp::createFromBson(specObj.firstElement(), getExpCtx()),
- UserException,
+ AssertionException,
ErrorCodes::FailedToParse);
}
TEST_F(DocumentSourceCurrentOpTest, ShouldFailToParseIfUnrecognisedParameterSpecified) {
const auto specObj = fromjson("{$currentOp:{foo:true}}");
ASSERT_THROWS_CODE(DocumentSourceCurrentOp::createFromBson(specObj.firstElement(), getExpCtx()),
- UserException,
+ AssertionException,
ErrorCodes::FailedToParse);
}
@@ -231,7 +231,7 @@ TEST_F(DocumentSourceCurrentOpTest, ShouldFailIfNoShardNameAvailableForShardedRe
const auto currentOp = DocumentSourceCurrentOp::create(getExpCtx());
currentOp->injectMongodInterface(mongod);
- ASSERT_THROWS_CODE(currentOp->getNext(), UserException, 40465);
+ ASSERT_THROWS_CODE(currentOp->getNext(), AssertionException, 40465);
}
TEST_F(DocumentSourceCurrentOpTest, ShouldFailIfOpIDIsNonNumericWhenModifyingInShardedContext) {
@@ -243,7 +243,7 @@ TEST_F(DocumentSourceCurrentOpTest, ShouldFailIfOpIDIsNonNumericWhenModifyingInS
const auto currentOp = DocumentSourceCurrentOp::create(getExpCtx());
currentOp->injectMongodInterface(mongod);
- ASSERT_THROWS_CODE(currentOp->getNext(), UserException, ErrorCodes::TypeMismatch);
+ ASSERT_THROWS_CODE(currentOp->getNext(), AssertionException, ErrorCodes::TypeMismatch);
}
} // namespace
diff --git a/src/mongo/db/pipeline/document_source_facet.cpp b/src/mongo/db/pipeline/document_source_facet.cpp
index e553ea2fa62..3c8cf9db359 100644
--- a/src/mongo/db/pipeline/document_source_facet.cpp
+++ b/src/mongo/db/pipeline/document_source_facet.cpp
@@ -72,7 +72,7 @@ namespace {
* Extracts the names of the facets and the vectors of raw BSONObjs representing the stages within
* that facet's pipeline.
*
- * Throws a UserException if it fails to parse for any reason.
+ * Throws a AssertionException if it fails to parse for any reason.
*/
vector<pair<string, vector<BSONObj>>> extractRawPipelines(const BSONElement& elem) {
uassert(40169,
diff --git a/src/mongo/db/pipeline/document_source_facet_test.cpp b/src/mongo/db/pipeline/document_source_facet_test.cpp
index d8798a5c70e..be05268fb7b 100644
--- a/src/mongo/db/pipeline/document_source_facet_test.cpp
+++ b/src/mongo/db/pipeline/document_source_facet_test.cpp
@@ -66,49 +66,60 @@ TEST_F(DocumentSourceFacetTest, ShouldRejectNonObjectSpec) {
auto ctx = getExpCtx();
auto spec = BSON("$facet"
<< "string");
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << 1);
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON_ARRAY(1 << 2));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldRejectEmptyObject) {
auto ctx = getExpCtx();
auto spec = BSON("$facet" << BSONObj());
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldRejectFacetsWithInvalidNames) {
auto ctx = getExpCtx();
auto spec = BSON("$facet" << BSON("" << BSON_ARRAY(BSON("$skip" << 4))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON("a.b" << BSON_ARRAY(BSON("$skip" << 4))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON("$a" << BSON_ARRAY(BSON("$skip" << 4))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldRejectNonArrayFacets) {
auto ctx = getExpCtx();
auto spec = BSON("$facet" << BSON("a" << 1));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON("a" << BSON_ARRAY(BSON("$skip" << 4)) << "b" << 2));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldRejectEmptyPipelines) {
auto ctx = getExpCtx();
auto spec = BSON("$facet" << BSON("a" << BSONArray()));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON("a" << BSON_ARRAY(BSON("$skip" << 4)) << "b" << BSONArray()));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldSucceedWhenNamespaceIsCollectionless) {
@@ -124,29 +135,35 @@ TEST_F(DocumentSourceFacetTest, ShouldRejectFacetsContainingAnOutStage) {
auto ctx = getExpCtx();
auto spec = BSON("$facet" << BSON("a" << BSON_ARRAY(BSON("$out"
<< "out_collection"))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec =
BSON("$facet" << BSON("a" << BSON_ARRAY(BSON("$skip" << 1) << BSON("$out"
<< "out_collection"))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON("a" << BSON_ARRAY(BSON("$out"
<< "out_collection")
<< BSON("$skip" << 1))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldRejectFacetsContainingAFacetStage) {
auto ctx = getExpCtx();
auto spec = fromjson("{$facet: {a: [{$facet: {a: [{$skip: 2}]}}]}}");
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = fromjson("{$facet: {a: [{$skip: 2}, {$facet: {a: [{$skip: 2}]}}]}}");
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = fromjson("{$facet: {a: [{$skip: 2}], b: [{$facet: {a: [{$skip: 2}]}}]}}");
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldAcceptLegalSpecification) {
@@ -599,7 +616,7 @@ TEST_F(DocumentSourceFacetTest, ShouldThrowIfAnyPipelineRequiresTextScoreButItIs
auto facetStage = DocumentSourceFacet::create(std::move(facets), ctx);
DepsTracker deps(DepsTracker::MetadataAvailable::kNoMetadata);
- ASSERT_THROWS(facetStage->getDependencies(&deps), UserException);
+ ASSERT_THROWS(facetStage->getDependencies(&deps), AssertionException);
}
/**
diff --git a/src/mongo/db/pipeline/document_source_graph_lookup_test.cpp b/src/mongo/db/pipeline/document_source_graph_lookup_test.cpp
index 0d693d81e25..feba9110eeb 100644
--- a/src/mongo/db/pipeline/document_source_graph_lookup_test.cpp
+++ b/src/mongo/db/pipeline/document_source_graph_lookup_test.cpp
@@ -105,7 +105,7 @@ TEST_F(DocumentSourceGraphLookUpTest,
graphLookupStage->injectMongodInterface(
std::make_shared<MockMongodImplementation>(std::move(fromContents)));
- ASSERT_THROWS_CODE(graphLookupStage->getNext(), UserException, 40271);
+ ASSERT_THROWS_CODE(graphLookupStage->getNext(), AssertionException, 40271);
}
TEST_F(DocumentSourceGraphLookUpTest,
@@ -135,7 +135,7 @@ TEST_F(DocumentSourceGraphLookUpTest,
graphLookupStage->injectMongodInterface(
std::make_shared<MockMongodImplementation>(std::move(fromContents)));
- ASSERT_THROWS_CODE(graphLookupStage->getNext(), UserException, 40271);
+ ASSERT_THROWS_CODE(graphLookupStage->getNext(), AssertionException, 40271);
}
TEST_F(DocumentSourceGraphLookUpTest,
@@ -165,7 +165,7 @@ TEST_F(DocumentSourceGraphLookUpTest,
std::make_shared<MockMongodImplementation>(std::move(fromContents)));
graphLookupStage->setSource(inputMock.get());
- ASSERT_THROWS_CODE(graphLookupStage->getNext(), UserException, 40271);
+ ASSERT_THROWS_CODE(graphLookupStage->getNext(), AssertionException, 40271);
}
bool arrayContains(const boost::intrusive_ptr<ExpressionContext>& expCtx,
diff --git a/src/mongo/db/pipeline/document_source_group.h b/src/mongo/db/pipeline/document_source_group.h
index 8b8094c94ee..cf108c15f24 100644
--- a/src/mongo/db/pipeline/document_source_group.h
+++ b/src/mongo/db/pipeline/document_source_group.h
@@ -63,7 +63,7 @@ public:
size_t maxMemoryUsageBytes = kDefaultMaxMemoryUsageBytes);
/**
- * Parses 'elem' into a $group stage, or throws a UserException if 'elem' was an invalid
+ * Parses 'elem' into a $group stage, or throws a AssertionException if 'elem' was an invalid
* specification.
*/
static boost::intrusive_ptr<DocumentSource> createFromBson(
diff --git a/src/mongo/db/pipeline/document_source_group_test.cpp b/src/mongo/db/pipeline/document_source_group_test.cpp
index 752312847ec..34e5a753e7a 100644
--- a/src/mongo/db/pipeline/document_source_group_test.cpp
+++ b/src/mongo/db/pipeline/document_source_group_test.cpp
@@ -158,7 +158,7 @@ TEST_F(DocumentSourceGroupTest, ShouldErrorIfNotAllowedToSpillToDiskAndResultSet
Document{{"_id", 1}, {"largeStr", largeStr}}});
group->setSource(mock.get());
- ASSERT_THROWS_CODE(group->getNext(), UserException, 16945);
+ ASSERT_THROWS_CODE(group->getNext(), AssertionException, 16945);
}
TEST_F(DocumentSourceGroupTest, ShouldCorrectlyTrackMemoryUsageBetweenPauses) {
@@ -186,7 +186,7 @@ TEST_F(DocumentSourceGroupTest, ShouldCorrectlyTrackMemoryUsageBetweenPauses) {
ASSERT_TRUE(group->getNext().isPaused());
// The next should realize it's used too much memory.
- ASSERT_THROWS_CODE(group->getNext(), UserException, 16945);
+ ASSERT_THROWS_CODE(group->getNext(), AssertionException, 16945);
}
BSONObj toBson(const intrusive_ptr<DocumentSource>& source) {
@@ -258,7 +258,7 @@ class ParseErrorBase : public Base {
public:
virtual ~ParseErrorBase() {}
void run() {
- ASSERT_THROWS(createGroup(spec()), UserException);
+ ASSERT_THROWS(createGroup(spec()), AssertionException);
}
protected:
@@ -302,7 +302,7 @@ public:
BSONObj spec = BSON("$group"
<< "foo");
BSONElement specElement = spec.firstElement();
- ASSERT_THROWS(DocumentSourceGroup::createFromBson(specElement, ctx()), UserException);
+ ASSERT_THROWS(DocumentSourceGroup::createFromBson(specElement, ctx()), AssertionException);
}
};
@@ -1101,7 +1101,7 @@ class ArrayConstantAccumulatorExpression : public CheckResultsBase {
public:
void run() {
// A parse exception is thrown when a raw array is provided to an accumulator.
- ASSERT_THROWS(createGroup(fromjson("{_id:1,a:{$push:[4,5,6]}}")), UserException);
+ ASSERT_THROWS(createGroup(fromjson("{_id:1,a:{$push:[4,5,6]}}")), AssertionException);
// Run standard base tests.
CheckResultsBase::run();
}
diff --git a/src/mongo/db/pipeline/document_source_lookup_change_post_image.h b/src/mongo/db/pipeline/document_source_lookup_change_post_image.h
index 5df6d7403d6..b11c79e44d3 100644
--- a/src/mongo/db/pipeline/document_source_lookup_change_post_image.h
+++ b/src/mongo/db/pipeline/document_source_lookup_change_post_image.h
@@ -106,7 +106,7 @@ private:
Value lookupPostImage(const Document& updateOp) const;
/**
- * Throws a UserException if the namespace found in 'inputDoc' doesn't match the one on the
+ * Throws a AssertionException if the namespace found in 'inputDoc' doesn't match the one on the
* ExpressionContext.
*/
NamespaceString assertNamespaceMatches(const Document& inputDoc) const;
diff --git a/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp b/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp
index c1d0c6d10fa..fdeea5bffc6 100644
--- a/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp
+++ b/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp
@@ -102,7 +102,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfMissingDocumentKeyO
lookupChangeStage->injectMongodInterface(
std::make_shared<MockMongodInterface>(deque<DocumentSource::GetNextResult>{}));
- ASSERT_THROWS_CODE(lookupChangeStage->getNext(), UserException, 40578);
+ ASSERT_THROWS_CODE(lookupChangeStage->getNext(), AssertionException, 40578);
}
TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfMissingOperationType) {
@@ -123,7 +123,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfMissingOperationTyp
lookupChangeStage->injectMongodInterface(
std::make_shared<MockMongodInterface>(deque<DocumentSource::GetNextResult>{}));
- ASSERT_THROWS_CODE(lookupChangeStage->getNext(), UserException, 40578);
+ ASSERT_THROWS_CODE(lookupChangeStage->getNext(), AssertionException, 40578);
}
TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfMissingNamespace) {
@@ -143,7 +143,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfMissingNamespace) {
lookupChangeStage->injectMongodInterface(
std::make_shared<MockMongodInterface>(deque<DocumentSource::GetNextResult>{}));
- ASSERT_THROWS_CODE(lookupChangeStage->getNext(), UserException, 40578);
+ ASSERT_THROWS_CODE(lookupChangeStage->getNext(), AssertionException, 40578);
}
TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfNsFieldHasWrongType) {
@@ -162,7 +162,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfNsFieldHasWrongType
lookupChangeStage->injectMongodInterface(
std::make_shared<MockMongodInterface>(deque<DocumentSource::GetNextResult>{}));
- ASSERT_THROWS_CODE(lookupChangeStage->getNext(), UserException, 40578);
+ ASSERT_THROWS_CODE(lookupChangeStage->getNext(), AssertionException, 40578);
}
TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfNsFieldDoesNotMatchPipeline) {
@@ -183,7 +183,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfNsFieldDoesNotMatch
lookupChangeStage->injectMongodInterface(
std::make_shared<MockMongodInterface>(deque<DocumentSource::GetNextResult>{}));
- ASSERT_THROWS_CODE(lookupChangeStage->getNext(), UserException, 40579);
+ ASSERT_THROWS_CODE(lookupChangeStage->getNext(), AssertionException, 40579);
}
TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfDocumentKeyIsNotUnique) {
@@ -206,7 +206,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfDocumentKeyIsNotUni
lookupChangeStage->injectMongodInterface(
std::make_shared<MockMongodInterface>(std::move(foreignCollection)));
- ASSERT_THROWS_CODE(lookupChangeStage->getNext(), UserException, 40580);
+ ASSERT_THROWS_CODE(lookupChangeStage->getNext(), AssertionException, 40580);
}
TEST_F(DocumentSourceLookupChangePostImageTest, ShouldPropagatePauses) {
diff --git a/src/mongo/db/pipeline/document_source_lookup_test.cpp b/src/mongo/db/pipeline/document_source_lookup_test.cpp
index f9aa416cac6..2f7ac7852e4 100644
--- a/src/mongo/db/pipeline/document_source_lookup_test.cpp
+++ b/src/mongo/db/pipeline/document_source_lookup_test.cpp
@@ -223,7 +223,7 @@ TEST_F(DocumentSourceLookUpTest, RejectsLocalFieldForeignFieldWhenPipelineIsSpec
<< "Expected creation of the "
<< lookupStage->getSourceName()
<< " stage to uassert on mix of localField/foreignField and pipeline options");
- } catch (const UserException& ex) {
+ } catch (const AssertionException& ex) {
ASSERT_EQ(ErrorCodes::FailedToParse, ex.code());
}
}
@@ -246,7 +246,7 @@ TEST_F(DocumentSourceLookUpTest, RejectsLocalFieldForeignFieldWhenLetIsSpecified
<< "as"))
.firstElement(),
expCtx),
- UserException,
+ AssertionException,
ErrorCodes::FailedToParse);
}
@@ -267,7 +267,7 @@ TEST_F(DocumentSourceLookUpTest, RejectsInvalidLetVariableName) {
<< "as"))
.firstElement(),
expCtx),
- UserException,
+ AssertionException,
16866);
ASSERT_THROWS_CODE(DocumentSourceLookUp::createFromBson(
@@ -282,7 +282,7 @@ TEST_F(DocumentSourceLookUpTest, RejectsInvalidLetVariableName) {
<< "as"))
.firstElement(),
expCtx),
- UserException,
+ AssertionException,
16867);
ASSERT_THROWS_CODE(DocumentSourceLookUp::createFromBson(
@@ -297,7 +297,7 @@ TEST_F(DocumentSourceLookUpTest, RejectsInvalidLetVariableName) {
<< "as"))
.firstElement(),
expCtx),
- UserException,
+ AssertionException,
16868);
}
diff --git a/src/mongo/db/pipeline/document_source_project_test.cpp b/src/mongo/db/pipeline/document_source_project_test.cpp
index 7512600ae73..5688d343675 100644
--- a/src/mongo/db/pipeline/document_source_project_test.cpp
+++ b/src/mongo/db/pipeline/document_source_project_test.cpp
@@ -88,7 +88,8 @@ TEST_F(ProjectStageTest, ShouldErrorOnNonObjectSpec) {
BSONObj spec = BSON("$project"
<< "foo");
BSONElement specElement = spec.firstElement();
- ASSERT_THROWS(DocumentSourceProject::createFromBson(specElement, getExpCtx()), UserException);
+ ASSERT_THROWS(DocumentSourceProject::createFromBson(specElement, getExpCtx()),
+ AssertionException);
}
/**
@@ -290,7 +291,7 @@ TEST_F(ProjectStageTest, CannotAddNestedDocumentExceedingDepthLimit) {
ASSERT_THROWS_CODE(
DocumentSourceProject::create(
makeProjectForNestedDocument(BSONDepth::getMaxAllowableDepth() + 1), getExpCtx()),
- UserException,
+ AssertionException,
ErrorCodes::Overflow);
}
} // namespace
diff --git a/src/mongo/db/pipeline/document_source_replace_root_test.cpp b/src/mongo/db/pipeline/document_source_replace_root_test.cpp
index 51411531022..321afbc8220 100644
--- a/src/mongo/db/pipeline/document_source_replace_root_test.cpp
+++ b/src/mongo/db/pipeline/document_source_replace_root_test.cpp
@@ -213,18 +213,18 @@ TEST_F(ReplaceRootBasics, ErrorsWhenNewRootDoesNotEvaluateToAnObject) {
// A string is not an object.
auto mock = DocumentSourceMock::create(Document{{"a", "hello"_sd}});
replaceRoot->setSource(mock.get());
- ASSERT_THROWS_CODE(replaceRoot->getNext(), UserException, 40228);
+ ASSERT_THROWS_CODE(replaceRoot->getNext(), AssertionException, 40228);
// An integer is not an object.
mock = DocumentSourceMock::create(Document{{"a", 5}});
replaceRoot->setSource(mock.get());
- ASSERT_THROWS_CODE(replaceRoot->getNext(), UserException, 40228);
+ ASSERT_THROWS_CODE(replaceRoot->getNext(), AssertionException, 40228);
// Literals are not objects.
replaceRoot = createReplaceRoot(BSON("newRoot" << BSON("$literal" << 1)));
mock = DocumentSourceMock::create(Document());
replaceRoot->setSource(mock.get());
- ASSERT_THROWS_CODE(replaceRoot->getNext(), UserException, 40228);
+ ASSERT_THROWS_CODE(replaceRoot->getNext(), AssertionException, 40228);
assertExhausted(replaceRoot);
// Most operator expressions do not resolve to objects.
@@ -232,7 +232,7 @@ TEST_F(ReplaceRootBasics, ErrorsWhenNewRootDoesNotEvaluateToAnObject) {
<< "$a")));
mock = DocumentSourceMock::create(Document{{"a", true}});
replaceRoot->setSource(mock.get());
- ASSERT_THROWS_CODE(replaceRoot->getNext(), UserException, 40228);
+ ASSERT_THROWS_CODE(replaceRoot->getNext(), AssertionException, 40228);
assertExhausted(replaceRoot);
}
@@ -244,12 +244,12 @@ TEST_F(ReplaceRootBasics, ErrorsIfNewRootFieldPathDoesNotExist) {
auto mock = DocumentSourceMock::create(Document());
replaceRoot->setSource(mock.get());
- ASSERT_THROWS_CODE(replaceRoot->getNext(), UserException, 40228);
+ ASSERT_THROWS_CODE(replaceRoot->getNext(), AssertionException, 40228);
assertExhausted(replaceRoot);
mock = DocumentSourceMock::create(Document{{"e", Document{{"b", Document{{"c", 3}}}}}});
replaceRoot->setSource(mock.get());
- ASSERT_THROWS_CODE(replaceRoot->getNext(), UserException, 40228);
+ ASSERT_THROWS_CODE(replaceRoot->getNext(), AssertionException, 40228);
assertExhausted(replaceRoot);
}
@@ -286,7 +286,7 @@ TEST_F(ReplaceRootBasics, ReplaceRootWithRemoveSystemVariableThrows) {
auto mock = DocumentSourceMock::create({inputDoc});
replaceRoot->setSource(mock.get());
- ASSERT_THROWS_CODE(replaceRoot->getNext(), UserException, 40228);
+ ASSERT_THROWS_CODE(replaceRoot->getNext(), AssertionException, 40228);
}
/**
@@ -310,10 +310,10 @@ public:
// Verify that the creation of a $replaceRoot stage requires an object specification
TEST_F(ReplaceRootSpec, CreationRequiresObjectSpecification) {
- ASSERT_THROWS_CODE(createReplaceRoot(BSON("$replaceRoot" << 1)), UserException, 40229);
+ ASSERT_THROWS_CODE(createReplaceRoot(BSON("$replaceRoot" << 1)), AssertionException, 40229);
ASSERT_THROWS_CODE(createReplaceRoot(BSON("$replaceRoot"
<< "string")),
- UserException,
+ AssertionException,
40229);
}
@@ -323,30 +323,31 @@ TEST_F(ReplaceRootSpec, OnlyValidOptionInObjectSpecIsNewRoot) {
<< "$a"
<< "root"
<< 2))),
- UserException,
+ AssertionException,
40230);
ASSERT_THROWS_CODE(createReplaceRoot(createSpec(BSON("newRoot"
<< "$a"
<< "path"
<< 2))),
- UserException,
+ AssertionException,
40230);
ASSERT_THROWS_CODE(createReplaceRoot(createSpec(BSON("path"
<< "$a"))),
- UserException,
+ AssertionException,
40230);
}
// Verify that $replaceRoot requires a valid expression as input to the newRoot option.
TEST_F(ReplaceRootSpec, RequiresExpressionForNewRootOption) {
- ASSERT_THROWS_CODE(createReplaceRoot(createSpec(BSONObj())), UserException, 40231);
+ ASSERT_THROWS_CODE(createReplaceRoot(createSpec(BSONObj())), AssertionException, 40231);
ASSERT_THROWS(createReplaceRoot(createSpec(BSON("newRoot"
<< "$$$a"))),
- UserException);
+ AssertionException);
ASSERT_THROWS(createReplaceRoot(createSpec(BSON("newRoot"
<< "$$a"))),
- UserException);
- ASSERT_THROWS(createReplaceRoot(createFullSpec(BSON("$map" << BSON("a" << 1)))), UserException);
+ AssertionException);
+ ASSERT_THROWS(createReplaceRoot(createFullSpec(BSON("$map" << BSON("a" << 1)))),
+ AssertionException);
}
// Verify that newRoot accepts all types of expressions.
diff --git a/src/mongo/db/pipeline/document_source_sample_test.cpp b/src/mongo/db/pipeline/document_source_sample_test.cpp
index 528676cb294..417a2ff5a34 100644
--- a/src/mongo/db/pipeline/document_source_sample_test.cpp
+++ b/src/mongo/db/pipeline/document_source_sample_test.cpp
@@ -220,32 +220,32 @@ public:
};
TEST_F(InvalidSampleSpec, NonObject) {
- ASSERT_THROWS_CODE(createSample(BSON("$sample" << 1)), UserException, 28745);
+ ASSERT_THROWS_CODE(createSample(BSON("$sample" << 1)), AssertionException, 28745);
ASSERT_THROWS_CODE(createSample(BSON("$sample"
<< "string")),
- UserException,
+ AssertionException,
28745);
}
TEST_F(InvalidSampleSpec, NonNumericSize) {
ASSERT_THROWS_CODE(createSample(createSpec(BSON("size"
<< "string"))),
- UserException,
+ AssertionException,
28746);
}
TEST_F(InvalidSampleSpec, NegativeSize) {
- ASSERT_THROWS_CODE(createSample(createSpec(BSON("size" << -1))), UserException, 28747);
- ASSERT_THROWS_CODE(createSample(createSpec(BSON("size" << -1.0))), UserException, 28747);
+ ASSERT_THROWS_CODE(createSample(createSpec(BSON("size" << -1))), AssertionException, 28747);
+ ASSERT_THROWS_CODE(createSample(createSpec(BSON("size" << -1.0))), AssertionException, 28747);
}
TEST_F(InvalidSampleSpec, ExtraOption) {
ASSERT_THROWS_CODE(
- createSample(createSpec(BSON("size" << 1 << "extra" << 2))), UserException, 28748);
+ createSample(createSpec(BSON("size" << 1 << "extra" << 2))), AssertionException, 28748);
}
TEST_F(InvalidSampleSpec, MissingSize) {
- ASSERT_THROWS_CODE(createSample(createSpec(BSONObj())), UserException, 28749);
+ ASSERT_THROWS_CODE(createSample(createSpec(BSONObj())), AssertionException, 28749);
}
//
@@ -344,7 +344,7 @@ TEST_F(SampleFromRandomCursorBasics, TooManyDups) {
ASSERT_TRUE(sample()->getNext().isAdvanced());
// The rest are duplicates, should error.
- ASSERT_THROWS_CODE(sample()->getNext(), UserException, 28799);
+ ASSERT_THROWS_CODE(sample()->getNext(), AssertionException, 28799);
}
/**
@@ -354,7 +354,7 @@ TEST_F(SampleFromRandomCursorBasics, MissingIdField) {
// Once with only a bad document.
createSample(2); // _idField is '_id'.
source()->queue.push_back(DOC("non_id" << 2));
- ASSERT_THROWS_CODE(sample()->getNext(), UserException, 28793);
+ ASSERT_THROWS_CODE(sample()->getNext(), AssertionException, 28793);
// Again, with some regular documents before a bad one.
createSample(2); // _idField is '_id'.
@@ -365,7 +365,7 @@ TEST_F(SampleFromRandomCursorBasics, MissingIdField) {
// First should be successful.
ASSERT_TRUE(sample()->getNext().isAdvanced());
- ASSERT_THROWS_CODE(sample()->getNext(), UserException, 28793);
+ ASSERT_THROWS_CODE(sample()->getNext(), AssertionException, 28793);
}
/**
diff --git a/src/mongo/db/pipeline/document_source_skip.h b/src/mongo/db/pipeline/document_source_skip.h
index a69f5e59eb5..8fc27a59f87 100644
--- a/src/mongo/db/pipeline/document_source_skip.h
+++ b/src/mongo/db/pipeline/document_source_skip.h
@@ -86,7 +86,7 @@ public:
/**
* Parses the user-supplied BSON into a $skip stage.
*
- * Throws a UserException if 'elem' is an invalid $skip specification.
+ * Throws a AssertionException if 'elem' is an invalid $skip specification.
*/
static boost::intrusive_ptr<DocumentSource> createFromBson(
BSONElement elem, const boost::intrusive_ptr<ExpressionContext>& pExpCtx);
diff --git a/src/mongo/db/pipeline/document_source_sort_by_count_test.cpp b/src/mongo/db/pipeline/document_source_sort_by_count_test.cpp
index 12975e96149..1bc21c0eab5 100644
--- a/src/mongo/db/pipeline/document_source_sort_by_count_test.cpp
+++ b/src/mongo/db/pipeline/document_source_sort_by_count_test.cpp
@@ -120,22 +120,22 @@ public:
TEST_F(InvalidSortByCountSpec, NonObjectNonStringSpec) {
BSONObj spec = BSON("$sortByCount" << 1);
- ASSERT_THROWS_CODE(createSortByCount(spec), UserException, 40149);
+ ASSERT_THROWS_CODE(createSortByCount(spec), AssertionException, 40149);
spec = BSON("$sortByCount" << BSONNULL);
- ASSERT_THROWS_CODE(createSortByCount(spec), UserException, 40149);
+ ASSERT_THROWS_CODE(createSortByCount(spec), AssertionException, 40149);
}
TEST_F(InvalidSortByCountSpec, NonExpressionInObjectSpec) {
BSONObj spec = BSON("$sortByCount" << BSON("field1"
<< "$x"));
- ASSERT_THROWS_CODE(createSortByCount(spec), UserException, 40147);
+ ASSERT_THROWS_CODE(createSortByCount(spec), AssertionException, 40147);
}
TEST_F(InvalidSortByCountSpec, NonFieldPathStringSpec) {
BSONObj spec = BSON("$sortByCount"
<< "test");
- ASSERT_THROWS_CODE(createSortByCount(spec), UserException, 40148);
+ ASSERT_THROWS_CODE(createSortByCount(spec), AssertionException, 40148);
}
} // namespace
diff --git a/src/mongo/db/pipeline/document_source_sort_test.cpp b/src/mongo/db/pipeline/document_source_sort_test.cpp
index 92b0f4dd07c..25362138a9c 100644
--- a/src/mongo/db/pipeline/document_source_sort_test.cpp
+++ b/src/mongo/db/pipeline/document_source_sort_test.cpp
@@ -95,26 +95,26 @@ private:
TEST_F(DocumentSourceSortTest, RejectsNonObjectSpec) {
BSONObj spec = BSON("$sort" << 1);
BSONElement specElement = spec.firstElement();
- ASSERT_THROWS(DocumentSourceSort::createFromBson(specElement, getExpCtx()), UserException);
+ ASSERT_THROWS(DocumentSourceSort::createFromBson(specElement, getExpCtx()), AssertionException);
}
TEST_F(DocumentSourceSortTest, RejectsEmptyObjectSpec) {
BSONObj spec = BSON("$sort" << BSONObj());
BSONElement specElement = spec.firstElement();
- ASSERT_THROWS(DocumentSourceSort::createFromBson(specElement, getExpCtx()), UserException);
+ ASSERT_THROWS(DocumentSourceSort::createFromBson(specElement, getExpCtx()), AssertionException);
}
TEST_F(DocumentSourceSortTest, RejectsSpecWithNonNumericValues) {
BSONObj spec = BSON("$sort" << BSON("a"
<< "b"));
BSONElement specElement = spec.firstElement();
- ASSERT_THROWS(DocumentSourceSort::createFromBson(specElement, getExpCtx()), UserException);
+ ASSERT_THROWS(DocumentSourceSort::createFromBson(specElement, getExpCtx()), AssertionException);
}
TEST_F(DocumentSourceSortTest, RejectsSpecWithZeroAsValue) {
BSONObj spec = BSON("$sort" << BSON("a" << 0));
BSONElement specElement = spec.firstElement();
- ASSERT_THROWS(DocumentSourceSort::createFromBson(specElement, getExpCtx()), UserException);
+ ASSERT_THROWS(DocumentSourceSort::createFromBson(specElement, getExpCtx()), AssertionException);
}
TEST_F(DocumentSourceSortTest, SortWithLimit) {
@@ -446,7 +446,7 @@ TEST_F(DocumentSourceSortExecutionTest,
Document{{"_id", 1}, {"largeStr", largeStr}}});
sort->setSource(mock.get());
- ASSERT_THROWS_CODE(sort->getNext(), UserException, 16819);
+ ASSERT_THROWS_CODE(sort->getNext(), AssertionException, 16819);
}
TEST_F(DocumentSourceSortExecutionTest, ShouldCorrectlyTrackMemoryUsageBetweenPauses) {
@@ -467,7 +467,7 @@ TEST_F(DocumentSourceSortExecutionTest, ShouldCorrectlyTrackMemoryUsageBetweenPa
ASSERT_TRUE(sort->getNext().isPaused());
// The next should realize it's used too much memory.
- ASSERT_THROWS_CODE(sort->getNext(), UserException, 16819);
+ ASSERT_THROWS_CODE(sort->getNext(), AssertionException, 16819);
}
} // namespace
diff --git a/src/mongo/db/pipeline/document_source_unwind_test.cpp b/src/mongo/db/pipeline/document_source_unwind_test.cpp
index 8dcf1ed9a32..8c01c50bde9 100644
--- a/src/mongo/db/pipeline/document_source_unwind_test.cpp
+++ b/src/mongo/db/pipeline/document_source_unwind_test.cpp
@@ -749,25 +749,26 @@ TEST_F(UnwindStageTest, UnwindIncludesIndexPathWhenIncludingIndex) {
//
TEST_F(UnwindStageTest, ShouldRejectNonObjectNonString) {
- ASSERT_THROWS_CODE(createUnwind(BSON("$unwind" << 1)), UserException, 15981);
+ ASSERT_THROWS_CODE(createUnwind(BSON("$unwind" << 1)), AssertionException, 15981);
}
TEST_F(UnwindStageTest, ShouldRejectSpecWithoutPath) {
- ASSERT_THROWS_CODE(createUnwind(BSON("$unwind" << BSONObj())), UserException, 28812);
+ ASSERT_THROWS_CODE(createUnwind(BSON("$unwind" << BSONObj())), AssertionException, 28812);
}
TEST_F(UnwindStageTest, ShouldRejectNonStringPath) {
- ASSERT_THROWS_CODE(createUnwind(BSON("$unwind" << BSON("path" << 2))), UserException, 28808);
+ ASSERT_THROWS_CODE(
+ createUnwind(BSON("$unwind" << BSON("path" << 2))), AssertionException, 28808);
}
TEST_F(UnwindStageTest, ShouldRejectNonDollarPrefixedPath) {
ASSERT_THROWS_CODE(createUnwind(BSON("$unwind"
<< "somePath")),
- UserException,
+ AssertionException,
28818);
ASSERT_THROWS_CODE(createUnwind(BSON("$unwind" << BSON("path"
<< "somePath"))),
- UserException,
+ AssertionException,
28818);
}
@@ -776,7 +777,7 @@ TEST_F(UnwindStageTest, ShouldRejectNonBoolPreserveNullAndEmptyArrays) {
<< "$x"
<< "preserveNullAndEmptyArrays"
<< 2))),
- UserException,
+ AssertionException,
28809);
}
@@ -785,7 +786,7 @@ TEST_F(UnwindStageTest, ShouldRejectNonStringIncludeArrayIndex) {
<< "$x"
<< "includeArrayIndex"
<< 2))),
- UserException,
+ AssertionException,
28810);
}
@@ -794,7 +795,7 @@ TEST_F(UnwindStageTest, ShouldRejectEmptyStringIncludeArrayIndex) {
<< "$x"
<< "includeArrayIndex"
<< ""))),
- UserException,
+ AssertionException,
28810);
}
@@ -803,13 +804,13 @@ TEST_F(UnwindStageTest, ShoudlRejectDollarPrefixedIncludeArrayIndex) {
<< "$x"
<< "includeArrayIndex"
<< "$"))),
- UserException,
+ AssertionException,
28822);
ASSERT_THROWS_CODE(createUnwind(BSON("$unwind" << BSON("path"
<< "$x"
<< "includeArrayIndex"
<< "$path"))),
- UserException,
+ AssertionException,
28822);
}
@@ -820,13 +821,13 @@ TEST_F(UnwindStageTest, ShouldRejectUnrecognizedOption) {
<< true
<< "foo"
<< 3))),
- UserException,
+ AssertionException,
28811);
ASSERT_THROWS_CODE(createUnwind(BSON("$unwind" << BSON("path"
<< "$x"
<< "foo"
<< 3))),
- UserException,
+ AssertionException,
28811);
}
diff --git a/src/mongo/db/pipeline/document_value_test.cpp b/src/mongo/db/pipeline/document_value_test.cpp
index 4cc91d023e1..34f993f1180 100644
--- a/src/mongo/db/pipeline/document_value_test.cpp
+++ b/src/mongo/db/pipeline/document_value_test.cpp
@@ -143,7 +143,7 @@ TEST(DocumentSerialization, CannotSerializeDocumentThatExceedsDepthLimit) {
Document doc(builder.obj());
BSONObjBuilder throwaway;
- ASSERT_THROWS_CODE(doc.toBson(&throwaway), UserException, ErrorCodes::Overflow);
+ ASSERT_THROWS_CODE(doc.toBson(&throwaway), AssertionException, ErrorCodes::Overflow);
throwaway.abandon();
}
@@ -582,7 +582,7 @@ TEST(MetaFields, BadSerialization) {
BufReader reader(bb.buf(), bb.len());
ASSERT_THROWS_CODE(
Document::deserializeForSorter(reader, Document::SorterDeserializeSettings()),
- UserException,
+ AssertionException,
28744);
}
} // namespace MetaFields
@@ -1035,7 +1035,7 @@ public:
virtual ~ToIntBase() {}
void run() {
if (asserts())
- ASSERT_THROWS(value().coerceToInt(), UserException);
+ ASSERT_THROWS(value().coerceToInt(), AssertionException);
else
ASSERT_EQUALS(expected(), value().coerceToInt());
}
@@ -1104,7 +1104,7 @@ class UndefinedToInt : public ToIntBase {
class StringToInt {
public:
void run() {
- ASSERT_THROWS(Value(StringData()).coerceToInt(), UserException);
+ ASSERT_THROWS(Value(StringData()).coerceToInt(), AssertionException);
}
};
@@ -1113,7 +1113,7 @@ public:
virtual ~ToLongBase() {}
void run() {
if (asserts())
- ASSERT_THROWS(value().coerceToLong(), UserException);
+ ASSERT_THROWS(value().coerceToLong(), AssertionException);
else
ASSERT_EQUALS(expected(), value().coerceToLong());
}
@@ -1182,7 +1182,7 @@ class UndefinedToLong : public ToLongBase {
class StringToLong {
public:
void run() {
- ASSERT_THROWS(Value(StringData()).coerceToLong(), UserException);
+ ASSERT_THROWS(Value(StringData()).coerceToLong(), AssertionException);
}
};
@@ -1191,7 +1191,7 @@ public:
virtual ~ToDoubleBase() {}
void run() {
if (asserts())
- ASSERT_THROWS(value().coerceToDouble(), UserException);
+ ASSERT_THROWS(value().coerceToDouble(), AssertionException);
else
ASSERT_EQUALS(expected(), value().coerceToDouble());
}
@@ -1261,7 +1261,7 @@ class UndefinedToDouble : public ToDoubleBase {
class StringToDouble {
public:
void run() {
- ASSERT_THROWS(Value(StringData()).coerceToDouble(), UserException);
+ ASSERT_THROWS(Value(StringData()).coerceToDouble(), AssertionException);
}
};
@@ -1304,7 +1304,7 @@ class TimestampToDate : public ToDateBase {
class StringToDate {
public:
void run() {
- ASSERT_THROWS(Value(StringData()).coerceToDate(), UserException);
+ ASSERT_THROWS(Value(StringData()).coerceToDate(), AssertionException);
}
};
@@ -1400,7 +1400,7 @@ class UndefinedToString : public ToStringBase {
class DocumentToString {
public:
void run() {
- ASSERT_THROWS(Value(mongo::Document()).coerceToString(), UserException);
+ ASSERT_THROWS(Value(mongo::Document()).coerceToString(), AssertionException);
}
};
@@ -1417,7 +1417,8 @@ public:
class DateToTimestamp {
public:
void run() {
- ASSERT_THROWS(Value(Date_t::fromMillisSinceEpoch(1010)).coerceToTimestamp(), UserException);
+ ASSERT_THROWS(Value(Date_t::fromMillisSinceEpoch(1010)).coerceToTimestamp(),
+ AssertionException);
}
};
diff --git a/src/mongo/db/pipeline/expression_test.cpp b/src/mongo/db/pipeline/expression_test.cpp
index b05a1bc1515..bd3abd1ffc3 100644
--- a/src/mongo/db/pipeline/expression_test.cpp
+++ b/src/mongo/db/pipeline/expression_test.cpp
@@ -980,7 +980,7 @@ public:
intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
intrusive_ptr<ExpressionNary> expression = new ExpressionAdd(expCtx);
expression->addOperand(ExpressionConstant::create(expCtx, Value("a"_sd)));
- ASSERT_THROWS(expression->evaluate(Document()), UserException);
+ ASSERT_THROWS(expression->evaluate(Document()), AssertionException);
}
};
@@ -991,7 +991,7 @@ public:
intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
intrusive_ptr<ExpressionNary> expression = new ExpressionAdd(expCtx);
expression->addOperand(ExpressionConstant::create(expCtx, Value(true)));
- ASSERT_THROWS(expression->evaluate(Document()), UserException);
+ ASSERT_THROWS(expression->evaluate(Document()), AssertionException);
}
};
@@ -1680,7 +1680,7 @@ public:
BSONObj specObject = BSON("" << spec());
BSONElement specElement = specObject.firstElement();
VariablesParseState vps = expCtx->variablesParseState;
- ASSERT_THROWS(Expression::parseOperand(expCtx, specElement, vps), UserException);
+ ASSERT_THROWS(Expression::parseOperand(expCtx, specElement, vps), AssertionException);
}
protected:
@@ -2186,7 +2186,7 @@ class Invalid {
public:
void run() {
intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
- ASSERT_THROWS(ExpressionFieldPath::create(expCtx, ""), UserException);
+ ASSERT_THROWS(ExpressionFieldPath::create(expCtx, ""), AssertionException);
}
};
@@ -2525,34 +2525,35 @@ TEST(ObjectParsing, ShouldAcceptExpressionAsValue) {
TEST(ExpressionObjectParse, ShouldRejectDottedFieldNames) {
intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
VariablesParseState vps = expCtx->variablesParseState;
- ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON("a.b" << 1), vps), UserException);
+ ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON("a.b" << 1), vps), AssertionException);
ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON("c" << 3 << "a.b" << 1), vps),
- UserException);
+ AssertionException);
ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON("a.b" << 1 << "c" << 3), vps),
- UserException);
+ AssertionException);
}
TEST(ExpressionObjectParse, ShouldRejectDuplicateFieldNames) {
intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
VariablesParseState vps = expCtx->variablesParseState;
- ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON("a" << 1 << "a" << 1), vps), UserException);
+ ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON("a" << 1 << "a" << 1), vps),
+ AssertionException);
ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON("a" << 1 << "b" << 2 << "a" << 1), vps),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ExpressionObject::parse(expCtx, BSON("a" << BSON("c" << 1) << "b" << 2 << "a" << 1), vps),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ExpressionObject::parse(expCtx, BSON("a" << 1 << "b" << 2 << "a" << BSON("c" << 1)), vps),
- UserException);
+ AssertionException);
}
TEST(ExpressionObjectParse, ShouldRejectInvalidFieldName) {
intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
VariablesParseState vps = expCtx->variablesParseState;
- ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON("$a" << 1), vps), UserException);
- ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON("" << 1), vps), UserException);
+ ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON("$a" << 1), vps), AssertionException);
+ ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON("" << 1), vps), AssertionException);
ASSERT_THROWS(ExpressionObject::parse(expCtx, BSON(std::string("a\0b", 3) << 1), vps),
- UserException);
+ AssertionException);
}
TEST(ExpressionObjectParse, ShouldRejectInvalidFieldPathAsValue) {
@@ -2562,7 +2563,7 @@ TEST(ExpressionObjectParse, ShouldRejectInvalidFieldPathAsValue) {
BSON("a"
<< "$field."),
vps),
- UserException);
+ AssertionException);
}
TEST(ParseObject, ShouldRejectExpressionAsTheSecondField) {
@@ -2571,7 +2572,7 @@ TEST(ParseObject, ShouldRejectExpressionAsTheSecondField) {
ASSERT_THROWS(
ExpressionObject::parse(
expCtx, BSON("a" << BSON("$and" << BSONArray()) << "$or" << BSONArray()), vps),
- UserException);
+ AssertionException);
}
//
@@ -3043,27 +3044,27 @@ TEST(ParseExpression, ShouldRecognizeConstExpression) {
}
TEST(ParseExpression, ShouldRejectUnknownExpression) {
- ASSERT_THROWS(parseExpression(BSON("$invalid" << 1)), UserException);
+ ASSERT_THROWS(parseExpression(BSON("$invalid" << 1)), AssertionException);
}
TEST(ParseExpression, ShouldRejectExpressionArgumentsWhichAreNotInArray) {
ASSERT_THROWS(parseExpression(BSON("$strcasecmp"
<< "foo")),
- UserException);
+ AssertionException);
}
TEST(ParseExpression, ShouldRejectExpressionWithWrongNumberOfArguments) {
- ASSERT_THROWS(parseExpression(BSON("$strcasecmp" << BSON_ARRAY("foo"))), UserException);
+ ASSERT_THROWS(parseExpression(BSON("$strcasecmp" << BSON_ARRAY("foo"))), AssertionException);
}
TEST(ParseExpression, ShouldRejectObjectWithTwoTopLevelExpressions) {
ASSERT_THROWS(parseExpression(BSON("$and" << BSONArray() << "$or" << BSONArray())),
- UserException);
+ AssertionException);
}
TEST(ParseExpression, ShouldRejectExpressionIfItsNotTheOnlyField) {
ASSERT_THROWS(parseExpression(BSON("$and" << BSONArray() << "a" << BSON("$or" << BSONArray()))),
- UserException);
+ AssertionException);
}
TEST(ParseExpression, ShouldParseExpressionWithMultipleArguments) {
@@ -3242,7 +3243,7 @@ public:
Expression::parseExpression(expCtx, obj, vps);
expr->evaluate(Document());
},
- UserException);
+ AssertionException);
}
}
}
@@ -3754,7 +3755,7 @@ TEST(ExpressionSubstrCPTest, DoesThrowWithBadContinuationByte) {
const auto continuationByte = "\x80\x00"_sd;
const auto expr = Expression::parseExpression(
expCtx, BSON("$substrCP" << BSON_ARRAY(continuationByte << 0 << 1)), vps);
- ASSERT_THROWS({ expr->evaluate(Document()); }, UserException);
+ ASSERT_THROWS({ expr->evaluate(Document()); }, AssertionException);
}
TEST(ExpressionSubstrCPTest, DoesThrowWithInvalidLeadingByte) {
@@ -3764,7 +3765,7 @@ TEST(ExpressionSubstrCPTest, DoesThrowWithInvalidLeadingByte) {
const auto leadingByte = "\xFF\x00"_sd;
const auto expr = Expression::parseExpression(
expCtx, BSON("$substrCP" << BSON_ARRAY(leadingByte << 0 << 1)), vps);
- ASSERT_THROWS({ expr->evaluate(Document()); }, UserException);
+ ASSERT_THROWS({ expr->evaluate(Document()); }, AssertionException);
}
TEST(ExpressionSubstrCPTest, WithStandardValue) {
@@ -3991,25 +3992,26 @@ TEST(ExpressionMergeObjects, MergingSingleArgumentArrayShouldUnwindAndMerge) {
TEST(ExpressionMergeObjects, MergingArrayWithDocumentShouldThrowException) {
std::vector<Document> first = {Document({{"a", 1}}), Document({{"a", 2}})};
auto second = Document({{"b", 2}});
- ASSERT_THROWS_CODE(evaluateExpression("$mergeObjects", {first, second}), UserException, 40400);
+ ASSERT_THROWS_CODE(
+ evaluateExpression("$mergeObjects", {first, second}), AssertionException, 40400);
}
TEST(ExpressionMergeObjects, MergingArrayContainingInvalidTypesShouldThrowException) {
std::vector<Value> first = {Value(Document({{"validType", 1}})), Value("invalidType"_sd)};
- ASSERT_THROWS_CODE(evaluateExpression("$mergeObjects", {first}), UserException, 40400);
+ ASSERT_THROWS_CODE(evaluateExpression("$mergeObjects", {first}), AssertionException, 40400);
}
TEST(ExpressionMergeObjects, MergingNonObjectsShouldThrowException) {
ASSERT_THROWS_CODE(
- evaluateExpression("$mergeObjects", {"invalidArg"_sd}), UserException, 40400);
+ evaluateExpression("$mergeObjects", {"invalidArg"_sd}), AssertionException, 40400);
ASSERT_THROWS_CODE(
evaluateExpression("$mergeObjects", {"invalidArg"_sd, Document({{"validArg", 1}})}),
- UserException,
+ AssertionException,
40400);
ASSERT_THROWS_CODE(evaluateExpression("$mergeObjects", {1, Document({{"validArg", 1}})}),
- UserException,
+ AssertionException,
40400);
}
@@ -4173,7 +4175,7 @@ public:
Expression::parseExpression(expCtx, obj, vps);
expr->evaluate(Document());
},
- UserException);
+ AssertionException);
}
}
}
@@ -4650,7 +4652,7 @@ TEST_F(DateExpressionTest, ParsingRejectsUnrecognizedFieldsInObjectSpecification
<< "extra"
<< 4));
ASSERT_THROWS_CODE(Expression::parseExpression(expCtx, spec, expCtx->variablesParseState),
- UserException,
+ AssertionException,
40535);
}
}
@@ -4660,7 +4662,7 @@ TEST_F(DateExpressionTest, ParsingRejectsEmptyObjectSpecification) {
for (auto&& expName : dateExpressions) {
BSONObj spec = BSON(expName << BSONObj());
ASSERT_THROWS_CODE(Expression::parseExpression(expCtx, spec, expCtx->variablesParseState),
- UserException,
+ AssertionException,
40539);
}
}
@@ -4671,7 +4673,7 @@ TEST_F(DateExpressionTest, RejectsEmptyArray) {
BSONObj spec = BSON(expName << BSONArray());
// It will parse as an ExpressionArray, and fail at runtime.
ASSERT_THROWS_CODE(Expression::parseExpression(expCtx, spec, expCtx->variablesParseState),
- UserException,
+ AssertionException,
40536);
}
}
@@ -4683,7 +4685,7 @@ TEST_F(DateExpressionTest, RejectsArraysWithMoreThanOneElement) {
<< "$tz"));
// It will parse as an ExpressionArray, and fail at runtime.
ASSERT_THROWS_CODE(Expression::parseExpression(expCtx, spec, expCtx->variablesParseState),
- UserException,
+ AssertionException,
40536);
}
}
@@ -4696,14 +4698,14 @@ TEST_F(DateExpressionTest, RejectsArraysWithinObjectSpecification) {
// It will parse as an ExpressionArray, and fail at runtime.
auto dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
auto contextDoc = Document{{"_id", 0}};
- ASSERT_THROWS_CODE(dateExp->evaluate(contextDoc), UserException, 16006);
+ ASSERT_THROWS_CODE(dateExp->evaluate(contextDoc), AssertionException, 16006);
// Test that it rejects an array for the timezone option.
spec =
BSON(expName << BSON("date" << Date_t{} << "timezone" << BSON_ARRAY("Europe/London")));
dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
contextDoc = Document{{"_id", 0}};
- ASSERT_THROWS_CODE(dateExp->evaluate(contextDoc), UserException, 40533);
+ ASSERT_THROWS_CODE(dateExp->evaluate(contextDoc), AssertionException, 40533);
}
}
@@ -4713,7 +4715,7 @@ TEST_F(DateExpressionTest, RejectsTypesThatCannotCoerceToDate) {
BSONObj spec = BSON(expName << "$stringField");
auto dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
auto contextDoc = Document{{"stringField", "string"_sd}};
- ASSERT_THROWS_CODE(dateExp->evaluate(contextDoc), UserException, 16006);
+ ASSERT_THROWS_CODE(dateExp->evaluate(contextDoc), AssertionException, 16006);
}
}
@@ -4744,7 +4746,7 @@ TEST_F(DateExpressionTest, RejectsNonStringTimezone) {
<< "$intField"));
auto dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
auto contextDoc = Document{{"intField", 4}};
- ASSERT_THROWS_CODE(dateExp->evaluate(contextDoc), UserException, 40533);
+ ASSERT_THROWS_CODE(dateExp->evaluate(contextDoc), AssertionException, 40533);
}
}
@@ -4755,7 +4757,7 @@ TEST_F(DateExpressionTest, RejectsUnrecognizedTimeZoneSpecification) {
<< "UNRECOGNIZED!"));
auto dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
auto contextDoc = Document{{"_id", 0}};
- ASSERT_THROWS_CODE(dateExp->evaluate(contextDoc), UserException, 40485);
+ ASSERT_THROWS_CODE(dateExp->evaluate(contextDoc), AssertionException, 40485);
}
}
@@ -5078,7 +5080,7 @@ TEST_F(ExpressionDateFromStringTest, RejectsUnparsableString) {
auto spec = BSON("$dateFromString" << BSON("dateString"
<< "60.Monday1770/06:59"));
auto dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
- ASSERT_THROWS_CODE(dateExp->evaluate({}), UserException, 40553);
+ ASSERT_THROWS_CODE(dateExp->evaluate({}), AssertionException, 40553);
}
TEST_F(ExpressionDateFromStringTest, RejectsTimeZoneInString) {
@@ -5087,12 +5089,12 @@ TEST_F(ExpressionDateFromStringTest, RejectsTimeZoneInString) {
auto spec = BSON("$dateFromString" << BSON("dateString"
<< "2017-07-13T10:02:57 Europe/London"));
auto dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
- ASSERT_THROWS_CODE(dateExp->evaluate({}), UserException, 40553);
+ ASSERT_THROWS_CODE(dateExp->evaluate({}), AssertionException, 40553);
spec = BSON("$dateFromString" << BSON("dateString"
<< "July 4, 2017 Europe/London"));
dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
- ASSERT_THROWS_CODE(dateExp->evaluate({}), UserException, 40553);
+ ASSERT_THROWS_CODE(dateExp->evaluate({}), AssertionException, 40553);
}
TEST_F(ExpressionDateFromStringTest, RejectsTimeZoneInStringAndArgument) {
@@ -5104,7 +5106,7 @@ TEST_F(ExpressionDateFromStringTest, RejectsTimeZoneInStringAndArgument) {
<< "timezone"
<< "Europe/London"));
auto dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
- ASSERT_THROWS_CODE(dateExp->evaluate({}), UserException, 40551);
+ ASSERT_THROWS_CODE(dateExp->evaluate({}), AssertionException, 40551);
// Test with timezone abbreviation and timezone
spec = BSON("$dateFromString" << BSON("dateString"
@@ -5112,7 +5114,7 @@ TEST_F(ExpressionDateFromStringTest, RejectsTimeZoneInStringAndArgument) {
<< "timezone"
<< "Europe/London"));
dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
- ASSERT_THROWS_CODE(dateExp->evaluate({}), UserException, 40551);
+ ASSERT_THROWS_CODE(dateExp->evaluate({}), AssertionException, 40551);
// Test with GMT offset and timezone
spec = BSON("$dateFromString" << BSON("dateString"
@@ -5120,7 +5122,7 @@ TEST_F(ExpressionDateFromStringTest, RejectsTimeZoneInStringAndArgument) {
<< "timezone"
<< "Europe/London"));
dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
- ASSERT_THROWS_CODE(dateExp->evaluate({}), UserException, 40554);
+ ASSERT_THROWS_CODE(dateExp->evaluate({}), AssertionException, 40554);
// Test with GMT offset and GMT timezone
spec = BSON("$dateFromString" << BSON("dateString"
@@ -5128,7 +5130,7 @@ TEST_F(ExpressionDateFromStringTest, RejectsTimeZoneInStringAndArgument) {
<< "timezone"
<< "GMT"));
dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);
- ASSERT_THROWS_CODE(dateExp->evaluate({}), UserException, 40554);
+ ASSERT_THROWS_CODE(dateExp->evaluate({}), AssertionException, 40554);
}
TEST_F(ExpressionDateFromStringTest, ReadWithUTCOffset) {
diff --git a/src/mongo/db/pipeline/field_path.h b/src/mongo/db/pipeline/field_path.h
index 2a93e607078..171bf89a5a3 100644
--- a/src/mongo/db/pipeline/field_path.h
+++ b/src/mongo/db/pipeline/field_path.h
@@ -42,7 +42,7 @@ namespace mongo {
class FieldPath {
public:
/**
- * Throws a UserException if a field name does not pass validation.
+ * Throws a AssertionException if a field name does not pass validation.
*/
static void uassertValidFieldName(StringData fieldName);
@@ -60,7 +60,8 @@ public:
}
/**
- * Throws a UserException if the string is empty or if any of the field names fail validation.
+ * Throws a AssertionException if the string is empty or if any of the field names fail
+ * validation.
*
* Field names are validated using uassertValidFieldName().
*/
diff --git a/src/mongo/db/pipeline/field_path_test.cpp b/src/mongo/db/pipeline/field_path_test.cpp
index 49d22eab885..5b586c84172 100644
--- a/src/mongo/db/pipeline/field_path_test.cpp
+++ b/src/mongo/db/pipeline/field_path_test.cpp
@@ -41,7 +41,7 @@ using std::vector;
/** FieldPath constructed from empty string. */
TEST(FieldPathTest, Empty) {
- ASSERT_THROWS(FieldPath path(""), UserException);
+ ASSERT_THROWS(FieldPath path(""), AssertionException);
}
/** FieldPath constructed from a simple string (without dots). */
@@ -55,12 +55,12 @@ TEST(FieldPathTest, Simple) {
/** FieldPath consisting of a '$' character. */
TEST(FieldPathTest, DollarSign) {
- ASSERT_THROWS(FieldPath path("$"), UserException);
+ ASSERT_THROWS(FieldPath path("$"), AssertionException);
}
/** FieldPath with a '$' prefix. */
TEST(FieldPathTest, DollarSignPrefix) {
- ASSERT_THROWS(FieldPath path("$a"), UserException);
+ ASSERT_THROWS(FieldPath path("$a"), AssertionException);
}
/** FieldPath constructed from a string with one dot. */
@@ -75,7 +75,7 @@ TEST(FieldPathTest, Dotted) {
/** FieldPath with a '$' prefix in the second field. */
TEST(FieldPathTest, DollarSignPrefixSecondField) {
- ASSERT_THROWS(FieldPath path("a.$b"), UserException);
+ ASSERT_THROWS(FieldPath path("a.$b"), AssertionException);
}
/** FieldPath constructed from a string with two dots. */
@@ -90,22 +90,22 @@ TEST(FieldPathTest, TwoDotted) {
/** FieldPath constructed from a string ending in a dot. */
TEST(FieldPathTest, TerminalDot) {
- ASSERT_THROWS(FieldPath path("foo."), UserException);
+ ASSERT_THROWS(FieldPath path("foo."), AssertionException);
}
/** FieldPath constructed from a string beginning with a dot. */
TEST(FieldPathTest, PrefixDot) {
- ASSERT_THROWS(FieldPath path(".foo"), UserException);
+ ASSERT_THROWS(FieldPath path(".foo"), AssertionException);
}
/** FieldPath constructed from a string with adjacent dots. */
TEST(FieldPathTest, AdjacentDots) {
- ASSERT_THROWS(FieldPath path("foo..bar"), UserException);
+ ASSERT_THROWS(FieldPath path("foo..bar"), AssertionException);
}
/** FieldPath constructed with only dots. */
TEST(FieldPathTest, OnlyDots) {
- ASSERT_THROWS(FieldPath path("..."), UserException);
+ ASSERT_THROWS(FieldPath path("..."), AssertionException);
}
/** FieldPath constructed from a string with one letter between two dots. */
@@ -117,7 +117,7 @@ TEST(FieldPathTest, LetterBetweenDots) {
/** FieldPath containing a null character. */
TEST(FieldPathTest, NullCharacter) {
- ASSERT_THROWS(FieldPath path(string("foo.b\0r", 7)), UserException);
+ ASSERT_THROWS(FieldPath path(string("foo.b\0r", 7)), AssertionException);
}
/** Tail of a FieldPath. */
@@ -157,7 +157,7 @@ TEST(FieldPathTest, CanConstructFieldPathAtOrUnderDepthLimit) {
// Tests that a FieldPath can't be constructed if the path is too deeply nested.
TEST(FieldPathTest, ConstructorAssertsOnDeeplyNestedPath) {
ASSERT_THROWS_CODE(FieldPath(makeFieldPathOfDepth(BSONDepth::getMaxAllowableDepth() + 1)),
- UserException,
+ AssertionException,
ErrorCodes::Overflow);
}
@@ -184,7 +184,7 @@ TEST(FieldPathTest, CanConstructArrayFieldPathAtOrUnderDepthLimit) {
// Tests that a FieldPath can't be constructed if an array path is too deeply nested.
TEST(FieldPathTest, ConstructorAssertsOnDeeplyNestedArrayPath) {
ASSERT_THROWS_CODE(makeArrayFieldPathOfDepth(BSONDepth::getMaxAllowableDepth() + 1),
- UserException,
+ AssertionException,
ErrorCodes::Overflow);
}
} // namespace
diff --git a/src/mongo/db/pipeline/granularity_rounder_powers_of_two_test.cpp b/src/mongo/db/pipeline/granularity_rounder_powers_of_two_test.cpp
index eefcdb749e5..4825682d6d7 100644
--- a/src/mongo/db/pipeline/granularity_rounder_powers_of_two_test.cpp
+++ b/src/mongo/db/pipeline/granularity_rounder_powers_of_two_test.cpp
@@ -225,8 +225,8 @@ TEST(GranularityRounderPowersOfTwoTest, ShouldFailOnRoundingNonNumericValues) {
// Make sure that each GranularityRounder fails when rounding a non-numeric value.
Value stringValue = Value("test"_sd);
- ASSERT_THROWS_CODE(rounder->roundUp(stringValue), UserException, 40265);
- ASSERT_THROWS_CODE(rounder->roundDown(stringValue), UserException, 40265);
+ ASSERT_THROWS_CODE(rounder->roundUp(stringValue), AssertionException, 40265);
+ ASSERT_THROWS_CODE(rounder->roundDown(stringValue), AssertionException, 40265);
}
TEST(GranularityRounderPowersOfTwoTest, ShouldFailOnRoundingNaN) {
@@ -234,15 +234,15 @@ TEST(GranularityRounderPowersOfTwoTest, ShouldFailOnRoundingNaN) {
GranularityRounder::getGranularityRounder(new ExpressionContextForTest(), "POWERSOF2");
Value nan = Value(std::nan("NaN"));
- ASSERT_THROWS_CODE(rounder->roundUp(nan), UserException, 40266);
- ASSERT_THROWS_CODE(rounder->roundDown(nan), UserException, 40266);
+ ASSERT_THROWS_CODE(rounder->roundUp(nan), AssertionException, 40266);
+ ASSERT_THROWS_CODE(rounder->roundDown(nan), AssertionException, 40266);
Value positiveNan = Value(Decimal128::kPositiveNaN);
Value negativeNan = Value(Decimal128::kNegativeNaN);
- ASSERT_THROWS_CODE(rounder->roundUp(positiveNan), UserException, 40266);
- ASSERT_THROWS_CODE(rounder->roundDown(positiveNan), UserException, 40266);
- ASSERT_THROWS_CODE(rounder->roundUp(negativeNan), UserException, 40266);
- ASSERT_THROWS_CODE(rounder->roundDown(negativeNan), UserException, 40266);
+ ASSERT_THROWS_CODE(rounder->roundUp(positiveNan), AssertionException, 40266);
+ ASSERT_THROWS_CODE(rounder->roundDown(positiveNan), AssertionException, 40266);
+ ASSERT_THROWS_CODE(rounder->roundUp(negativeNan), AssertionException, 40266);
+ ASSERT_THROWS_CODE(rounder->roundDown(negativeNan), AssertionException, 40266);
}
TEST(GranularityRounderPowersOfTwoTest, ShouldFailOnRoundingNegativeNumber) {
@@ -250,8 +250,8 @@ TEST(GranularityRounderPowersOfTwoTest, ShouldFailOnRoundingNegativeNumber) {
GranularityRounder::getGranularityRounder(new ExpressionContextForTest(), "POWERSOF2");
Value negativeNumber = Value(-1);
- ASSERT_THROWS_CODE(rounder->roundUp(negativeNumber), UserException, 40267);
- ASSERT_THROWS_CODE(rounder->roundDown(negativeNumber), UserException, 40267);
+ ASSERT_THROWS_CODE(rounder->roundUp(negativeNumber), AssertionException, 40267);
+ ASSERT_THROWS_CODE(rounder->roundDown(negativeNumber), AssertionException, 40267);
}
} // namespace
} // namespace mongo
diff --git a/src/mongo/db/pipeline/granularity_rounder_preferred_numbers_test.cpp b/src/mongo/db/pipeline/granularity_rounder_preferred_numbers_test.cpp
index 89df39621ad..f80281f8fe0 100644
--- a/src/mongo/db/pipeline/granularity_rounder_preferred_numbers_test.cpp
+++ b/src/mongo/db/pipeline/granularity_rounder_preferred_numbers_test.cpp
@@ -532,8 +532,8 @@ TEST(GranularityRounderPreferredNumbersTest, ShouldFailOnRoundingNonNumericValue
// Make sure that each GranularityRounder fails when rounding a non-numeric value.
Value stringValue = Value("test"_sd);
- ASSERT_THROWS_CODE(rounder->roundUp(stringValue), UserException, 40262);
- ASSERT_THROWS_CODE(rounder->roundDown(stringValue), UserException, 40262);
+ ASSERT_THROWS_CODE(rounder->roundUp(stringValue), AssertionException, 40262);
+ ASSERT_THROWS_CODE(rounder->roundDown(stringValue), AssertionException, 40262);
}
}
@@ -544,15 +544,15 @@ TEST(GranularityRounderPreferredNumbersTest, ShouldFailOnRoundingNaN) {
// Make sure that each GranularityRounder fails when rounding NaN.
Value nan = Value(std::nan("NaN"));
- ASSERT_THROWS_CODE(rounder->roundUp(nan), UserException, 40263);
- ASSERT_THROWS_CODE(rounder->roundDown(nan), UserException, 40263);
+ ASSERT_THROWS_CODE(rounder->roundUp(nan), AssertionException, 40263);
+ ASSERT_THROWS_CODE(rounder->roundDown(nan), AssertionException, 40263);
Value positiveNan = Value(Decimal128::kPositiveNaN);
Value negativeNan = Value(Decimal128::kNegativeNaN);
- ASSERT_THROWS_CODE(rounder->roundUp(positiveNan), UserException, 40263);
- ASSERT_THROWS_CODE(rounder->roundDown(positiveNan), UserException, 40263);
- ASSERT_THROWS_CODE(rounder->roundUp(negativeNan), UserException, 40263);
- ASSERT_THROWS_CODE(rounder->roundDown(negativeNan), UserException, 40263);
+ ASSERT_THROWS_CODE(rounder->roundUp(positiveNan), AssertionException, 40263);
+ ASSERT_THROWS_CODE(rounder->roundDown(positiveNan), AssertionException, 40263);
+ ASSERT_THROWS_CODE(rounder->roundUp(negativeNan), AssertionException, 40263);
+ ASSERT_THROWS_CODE(rounder->roundDown(negativeNan), AssertionException, 40263);
}
}
@@ -563,12 +563,12 @@ TEST(GranularityRounderPreferredNumbersTest, ShouldFailOnRoundingNegativeNumber)
// Make sure that each GranularityRounder fails when rounding a negative number.
Value negativeNumber = Value(-1);
- ASSERT_THROWS_CODE(rounder->roundUp(negativeNumber), UserException, 40268);
- ASSERT_THROWS_CODE(rounder->roundDown(negativeNumber), UserException, 40268);
+ ASSERT_THROWS_CODE(rounder->roundUp(negativeNumber), AssertionException, 40268);
+ ASSERT_THROWS_CODE(rounder->roundDown(negativeNumber), AssertionException, 40268);
negativeNumber = Value(Decimal128(-1));
- ASSERT_THROWS_CODE(rounder->roundUp(negativeNumber), UserException, 40268);
- ASSERT_THROWS_CODE(rounder->roundDown(negativeNumber), UserException, 40268);
+ ASSERT_THROWS_CODE(rounder->roundUp(negativeNumber), AssertionException, 40268);
+ ASSERT_THROWS_CODE(rounder->roundDown(negativeNumber), AssertionException, 40268);
}
}
} // namespace
diff --git a/src/mongo/db/pipeline/lite_parsed_document_source.h b/src/mongo/db/pipeline/lite_parsed_document_source.h
index 3ce5fdc6324..60e2e8bd8ee 100644
--- a/src/mongo/db/pipeline/lite_parsed_document_source.h
+++ b/src/mongo/db/pipeline/lite_parsed_document_source.h
@@ -72,7 +72,8 @@ public:
static void registerParser(const std::string& name, Parser parser);
/**
- * Constructs a LiteParsedDocumentSource from the user-supplied BSON, or throws a UserException.
+ * Constructs a LiteParsedDocumentSource from the user-supplied BSON, or throws a
+ * AssertionException.
*
* Extracts the first field name from 'spec', and delegates to the parser that was registered
* with that field name using registerParser() above.
diff --git a/src/mongo/db/pipeline/lite_parsed_pipeline.h b/src/mongo/db/pipeline/lite_parsed_pipeline.h
index f7aaab26b92..a83a1e3c8a0 100644
--- a/src/mongo/db/pipeline/lite_parsed_pipeline.h
+++ b/src/mongo/db/pipeline/lite_parsed_pipeline.h
@@ -47,7 +47,7 @@ public:
/**
* Constructs a LiteParsedPipeline from the raw BSON stages given in 'request'.
*
- * May throw a UserException if there is an invalid stage specification, although full
+ * May throw a AssertionException if there is an invalid stage specification, although full
* validation happens later, during Pipeline construction.
*/
LiteParsedPipeline(const AggregationRequest& request) {
diff --git a/src/mongo/db/pipeline/parsed_add_fields_test.cpp b/src/mongo/db/pipeline/parsed_add_fields_test.cpp
index 289e8eb1f33..1191ea21cb5 100644
--- a/src/mongo/db/pipeline/parsed_add_fields_test.cpp
+++ b/src/mongo/db/pipeline/parsed_add_fields_test.cpp
@@ -55,35 +55,40 @@ using std::vector;
TEST(ParsedAddFieldsSpec, ThrowsOnCreationWithConflictingFieldPaths) {
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
// These specs contain the same exact path.
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a" << 1 << "a" << 2)), UserException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a" << 1 << "a" << 2)), AssertionException);
ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a" << BSON("b" << 1 << "b" << 2))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("_id" << 3 << "_id" << true)),
- UserException);
+ AssertionException);
// These specs contain overlapping paths.
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a" << 1 << "a.b" << 2)), UserException);
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a.b.c" << 1 << "a" << 2)), UserException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a" << 1 << "a.b" << 2)),
+ AssertionException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a.b.c" << 1 << "a" << 2)),
+ AssertionException);
ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("_id" << true << "_id.x" << true)),
- UserException);
+ AssertionException);
}
// Verify that ParsedAddFields rejects specifications that contain invalid field paths.
TEST(ParsedAddFieldsSpec, ThrowsOnCreationWithInvalidFieldPath) {
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
// Dotted subfields are not allowed.
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a" << BSON("b.c" << true))), UserException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a" << BSON("b.c" << true))),
+ AssertionException);
// The user cannot start a field with $.
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("$dollar" << 0)), UserException);
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("c.$d" << true)), UserException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("$dollar" << 0)), AssertionException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("c.$d" << true)), AssertionException);
// Empty field names should throw an error.
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("" << 2)), UserException);
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a" << BSON("" << true))), UserException);
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("" << BSON("a" << true))), UserException);
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a." << true)), UserException);
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON(".a" << true)), UserException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("" << 2)), AssertionException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a" << BSON("" << true))),
+ AssertionException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("" << BSON("a" << true))),
+ AssertionException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a." << true)), AssertionException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON(".a" << true)), AssertionException);
}
// Verify that ParsedAddFields rejects specifications that contain empty objects or invalid
@@ -93,20 +98,20 @@ TEST(ParsedAddFieldsSpec, ThrowsOnCreationWithInvalidObjectsOrExpressions) {
// Invalid expressions should be rejected.
ASSERT_THROWS(ParsedAddFields::create(
expCtx, BSON("a" << BSON("$add" << BSON_ARRAY(4 << 2) << "b" << 1))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAddFields::create(expCtx,
BSON("a" << BSON("$gt" << BSON("bad"
<< "arguments")))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAddFields::create(
expCtx, BSON("a" << false << "b" << BSON("$unknown" << BSON_ARRAY(4 << 2)))),
- UserException);
+ AssertionException);
// Empty specifications are not allowed.
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSONObj()), UserException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSONObj()), AssertionException);
// Empty nested objects are not allowed.
- ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a" << BSONObj())), UserException);
+ ASSERT_THROWS(ParsedAddFields::create(expCtx, BSON("a" << BSONObj())), AssertionException);
}
TEST(ParsedAddFields, DoesNotErrorOnTwoNestedFields) {
diff --git a/src/mongo/db/pipeline/parsed_aggregation_projection.cpp b/src/mongo/db/pipeline/parsed_aggregation_projection.cpp
index 1588e796970..403d290d054 100644
--- a/src/mongo/db/pipeline/parsed_aggregation_projection.cpp
+++ b/src/mongo/db/pipeline/parsed_aggregation_projection.cpp
@@ -188,7 +188,7 @@ private:
* Delegates to parseSubObject() if 'elem' is an object. Otherwise updates '_parsedType' if
* appropriate.
*
- * Throws a UserException if this element represents a mix of projection types.
+ * Throws a AssertionException if this element represents a mix of projection types.
*/
void parseElement(const BSONElement& elem, const FieldPath& pathToElem) {
if (elem.type() == BSONType::Object) {
@@ -230,7 +230,7 @@ private:
/**
* Traverses 'thisLevelSpec', parsing each element in turn.
*
- * Throws a UserException if 'thisLevelSpec' represents an invalid mix of projections.
+ * Throws a AssertionException if 'thisLevelSpec' represents an invalid mix of projections.
*/
void parseNestedObject(const BSONObj& thisLevelSpec, const FieldPath& prefix) {
diff --git a/src/mongo/db/pipeline/parsed_aggregation_projection.h b/src/mongo/db/pipeline/parsed_aggregation_projection.h
index 126254ce908..96611be19dc 100644
--- a/src/mongo/db/pipeline/parsed_aggregation_projection.h
+++ b/src/mongo/db/pipeline/parsed_aggregation_projection.h
@@ -112,7 +112,7 @@ public:
/**
* Main entry point for a ParsedAggregationProjection.
*
- * Throws a UserException if 'spec' is an invalid projection specification.
+ * Throws a AssertionException if 'spec' is an invalid projection specification.
*/
static std::unique_ptr<ParsedAggregationProjection> create(
const boost::intrusive_ptr<ExpressionContext>& expCtx, const BSONObj& spec);
diff --git a/src/mongo/db/pipeline/parsed_aggregation_projection_test.cpp b/src/mongo/db/pipeline/parsed_aggregation_projection_test.cpp
index 2ee53275e6a..35544d8d1f6 100644
--- a/src/mongo/db/pipeline/parsed_aggregation_projection_test.cpp
+++ b/src/mongo/db/pipeline/parsed_aggregation_projection_test.cpp
@@ -57,73 +57,73 @@ TEST(ParsedAggregationProjectionErrors, ShouldRejectDuplicateFieldNames) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
// Include/exclude the same field twice.
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a" << true << "a" << true)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a" << false << "a" << false)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a" << BSON("b" << false << "b" << false))),
- UserException);
+ AssertionException);
// Mix of include/exclude and adding a field.
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("a" << wrapInLiteral(1) << "a" << true)),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("a" << false << "a" << wrapInLiteral(0))),
- UserException);
+ AssertionException);
// Adding the same field twice.
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a" << wrapInLiteral(1) << "a" << wrapInLiteral(0))),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldRejectDuplicateIds) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
// Include/exclude _id twice.
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("_id" << true << "_id" << true)),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("_id" << false << "_id" << false)),
- UserException);
+ AssertionException);
// Mix of including/excluding and adding _id.
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("_id" << wrapInLiteral(1) << "_id" << true)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("_id" << false << "_id" << wrapInLiteral(0))),
- UserException);
+ AssertionException);
// Adding _id twice.
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("_id" << wrapInLiteral(1) << "_id" << wrapInLiteral(0))),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldRejectFieldsWithSharedPrefix) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
// Include/exclude Fields with a shared prefix.
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a" << true << "a.b" << true)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a.b" << false << "a" << false)),
- UserException);
+ AssertionException);
// Mix of include/exclude and adding a shared prefix.
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("a" << wrapInLiteral(1) << "a.b" << true)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a.b" << false << "a" << wrapInLiteral(0))),
- UserException);
+ AssertionException);
// Adding a shared prefix twice.
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a" << wrapInLiteral(1) << "a.b" << wrapInLiteral(0))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a.b.c.d" << wrapInLiteral(1) << "a.b.c" << wrapInLiteral(0))),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldRejectMixOfIdAndSubFieldsOfId) {
@@ -131,213 +131,224 @@ TEST(ParsedAggregationProjectionErrors, ShouldRejectMixOfIdAndSubFieldsOfId) {
// Include/exclude _id twice.
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("_id" << true << "_id.x" << true)),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("_id.x" << false << "_id" << false)),
- UserException);
+ AssertionException);
// Mix of including/excluding and adding _id.
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("_id" << wrapInLiteral(1) << "_id.x" << true)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("_id.x" << false << "_id" << wrapInLiteral(0))),
- UserException);
+ AssertionException);
// Adding _id twice.
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("_id" << wrapInLiteral(1) << "_id.x" << wrapInLiteral(0))),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(
expCtx, BSON("_id.b.c.d" << wrapInLiteral(1) << "_id.b.c" << wrapInLiteral(0))),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldRejectMixOfInclusionAndExclusion) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
// Simple mix.
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a" << true << "b" << false)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a" << false << "b" << true)),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("a" << BSON("b" << false << "c" << true))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("_id" << BSON("b" << false << "c" << true))),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("_id.b" << false << "a.c" << true)),
- UserException);
+ AssertionException);
// Mix while also adding a field.
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a" << true << "b" << wrapInLiteral(1) << "c" << false)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a" << false << "b" << wrapInLiteral(1) << "c" << true)),
- UserException);
+ AssertionException);
// Mixing "_id" inclusion with exclusion.
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("_id" << true << "a" << false)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a" << false << "_id" << true)),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("_id" << true << "a.b.c" << false)),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("_id.x" << true << "a.b.c" << false)),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionType, ShouldRejectMixOfExclusionAndComputedFields) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("a" << false << "b" << wrapInLiteral(1))),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("a" << wrapInLiteral(1) << "b" << false)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a.b" << false << "a.c" << wrapInLiteral(1))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a.b" << wrapInLiteral(1) << "a.c" << false)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a" << BSON("b" << false << "c" << wrapInLiteral(1)))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a" << BSON("b" << wrapInLiteral(1) << "c" << false))),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldRejectDottedFieldInSubDocument) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a" << BSON("b.c" << true))),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("a" << BSON("b.c" << wrapInLiteral(1)))),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldRejectFieldNamesStartingWithADollar) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("$dollar" << 0)), UserException);
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("$dollar" << 1)), UserException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("$dollar" << 0)),
+ AssertionException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("$dollar" << 1)),
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("b.$dollar" << 0)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("b.$dollar" << 1)),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("b" << BSON("$dollar" << 0))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("b" << BSON("$dollar" << 1))),
- UserException);
+ AssertionException);
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("$add" << 0)), UserException);
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("$add" << 1)), UserException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("$add" << 0)),
+ AssertionException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("$add" << 1)),
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldRejectTopLevelExpressions) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("$add" << BSON_ARRAY(4 << 2))),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldRejectExpressionWithMultipleFieldNames) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a" << BSON("$add" << BSON_ARRAY(4 << 2) << "b" << 1))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a" << BSON("b" << 1 << "$add" << BSON_ARRAY(4 << 2)))),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(
expCtx, BSON("a" << BSON("b" << BSON("c" << 1 << "$add" << BSON_ARRAY(4 << 2))))),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(
expCtx, BSON("a" << BSON("b" << BSON("$add" << BSON_ARRAY(4 << 2) << "c" << 1)))),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldRejectEmptyProjection) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSONObj()), UserException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSONObj()), AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldRejectEmptyNestedObject) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a" << BSONObj())),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("a" << false << "b" << BSONObj())),
- UserException);
+ AssertionException);
ASSERT_THROWS(
ParsedAggregationProjection::create(expCtx, BSON("a" << true << "b" << BSONObj())),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a.b" << BSONObj())),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a" << BSON("b" << BSONObj()))),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldErrorOnInvalidExpression) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a" << false << "b" << BSON("$unknown" << BSON_ARRAY(4 << 2)))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(
expCtx, BSON("a" << true << "b" << BSON("$unknown" << BSON_ARRAY(4 << 2)))),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldErrorOnInvalidFieldPath) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
// Empty field names.
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("" << wrapInLiteral(2))),
- UserException);
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("" << true)), UserException);
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("" << false)), UserException);
+ AssertionException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("" << true)),
+ AssertionException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("" << false)),
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a" << BSON("" << true))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a" << BSON("" << false))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("" << BSON("a" << true))),
- UserException);
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("" << BSON("a" << false))),
- UserException);
+ AssertionException);
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a." << true)), UserException);
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a." << false)), UserException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a." << true)),
+ AssertionException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("a." << false)),
+ AssertionException);
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON(".a" << true)), UserException);
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON(".a" << false)), UserException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON(".a" << true)),
+ AssertionException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON(".a" << false)),
+ AssertionException);
// Not testing field names with null bytes, since that is invalid BSON, and won't make it to the
// $project stage without a previous error.
// Field names starting with '$'.
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("$x" << wrapInLiteral(2))),
- UserException);
- ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("c.$d" << true)), UserException);
+ AssertionException);
+ ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("c.$d" << true)),
+ AssertionException);
ASSERT_THROWS(ParsedAggregationProjection::create(expCtx, BSON("c.$d" << false)),
- UserException);
+ AssertionException);
}
TEST(ParsedAggregationProjectionErrors, ShouldNotErrorOnTwoNestedFields) {
diff --git a/src/mongo/db/pipeline/parsed_inclusion_projection_test.cpp b/src/mongo/db/pipeline/parsed_inclusion_projection_test.cpp
index ef77bb03943..799ac5f92b3 100644
--- a/src/mongo/db/pipeline/parsed_inclusion_projection_test.cpp
+++ b/src/mongo/db/pipeline/parsed_inclusion_projection_test.cpp
@@ -57,13 +57,13 @@ TEST(InclusionProjection, ShouldThrowWhenParsingInvalidExpression) {
ParsedInclusionProjection inclusion(expCtx);
ASSERT_THROWS(inclusion.parse(BSON("a" << BSON("$gt" << BSON("bad"
<< "arguments")))),
- UserException);
+ AssertionException);
}
TEST(InclusionProjection, ShouldRejectProjectionWithNoOutputFields) {
const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
ParsedInclusionProjection inclusion(expCtx);
- ASSERT_THROWS(inclusion.parse(BSON("_id" << false)), UserException);
+ ASSERT_THROWS(inclusion.parse(BSON("_id" << false)), AssertionException);
}
TEST(InclusionProjection, ShouldAddIncludedFieldsToDependencies) {
diff --git a/src/mongo/db/pipeline/pipeline_test.cpp b/src/mongo/db/pipeline/pipeline_test.cpp
index ac54c766727..79e324d3901 100644
--- a/src/mongo/db/pipeline/pipeline_test.cpp
+++ b/src/mongo/db/pipeline/pipeline_test.cpp
@@ -1670,7 +1670,7 @@ TEST_F(PipelineDependenciesTest, ShouldThrowIfTextScoreIsNeededButNotPresent) {
auto pipeline = unittest::assertGet(Pipeline::create({needsText}, ctx));
ASSERT_THROWS(pipeline->getDependencies(DepsTracker::MetadataAvailable::kNoMetadata),
- UserException);
+ AssertionException);
}
TEST_F(PipelineDependenciesTest, ShouldRequireTextScoreIfAvailableAndNoStageReturnsExhaustiveMeta) {
diff --git a/src/mongo/db/pipeline/tee_buffer_test.cpp b/src/mongo/db/pipeline/tee_buffer_test.cpp
index 2e4495c3d5f..52f3922de57 100644
--- a/src/mongo/db/pipeline/tee_buffer_test.cpp
+++ b/src/mongo/db/pipeline/tee_buffer_test.cpp
@@ -40,12 +40,12 @@ namespace mongo {
namespace {
TEST(TeeBufferTest, ShouldRequireAtLeastOneConsumer) {
- ASSERT_THROWS_CODE(TeeBuffer::create(0), UserException, 40309);
+ ASSERT_THROWS_CODE(TeeBuffer::create(0), AssertionException, 40309);
}
TEST(TeeBufferTest, ShouldRequirePositiveBatchSize) {
- ASSERT_THROWS_CODE(TeeBuffer::create(1, 0), UserException, 40310);
- ASSERT_THROWS_CODE(TeeBuffer::create(1, -2), UserException, 40310);
+ ASSERT_THROWS_CODE(TeeBuffer::create(1, 0), AssertionException, 40310);
+ ASSERT_THROWS_CODE(TeeBuffer::create(1, -2), AssertionException, 40310);
}
TEST(TeeBufferTest, ShouldBeExhaustedIfInputIsExhausted) {
diff --git a/src/mongo/db/pipeline/value.h b/src/mongo/db/pipeline/value.h
index 40c05d89b9a..d2d337fa3ea 100644
--- a/src/mongo/db/pipeline/value.h
+++ b/src/mongo/db/pipeline/value.h
@@ -200,8 +200,8 @@ public:
/**
* Recursively serializes this value as a field in the object in 'builder' with the field name
- * 'fieldName'. This function throws a UserException if the recursion exceeds the server's BSON
- * depth limit.
+ * 'fieldName'. This function throws a AssertionException if the recursion exceeds the server's
+ * BSON depth limit.
*/
void addToBsonObj(BSONObjBuilder* builder,
StringData fieldName,
@@ -209,7 +209,7 @@ public:
/**
* Recursively serializes this value as an element in the array in 'builder'. This function
- * throws a UserException if the recursion exceeds the server's BSON depth limit.
+ * throws a AssertionException if the recursion exceeds the server's BSON depth limit.
*/
void addToBsonArray(BSONArrayBuilder* builder, size_t recursionLevel = 1) const;
diff --git a/src/mongo/db/query/collation/collation_index_key_test.cpp b/src/mongo/db/query/collation/collation_index_key_test.cpp
index 88d635187a3..22e22fb7394 100644
--- a/src/mongo/db/query/collation/collation_index_key_test.cpp
+++ b/src/mongo/db/query/collation/collation_index_key_test.cpp
@@ -154,7 +154,7 @@ TEST(CollationIndexKeyTest, CollationAwareAppendThrowsIfSymbol) {
BSONObjBuilder out;
ASSERT_THROWS_CODE(
CollationIndexKey::collationAwareIndexKeyAppend(dataObj.firstElement(), &collator, &out),
- UserException,
+ AssertionException,
ErrorCodes::CannotBuildIndexKeys);
}
@@ -175,7 +175,7 @@ TEST(CollationIndexKeyTest, CollationAwareAppendThrowsIfSymbolInsideObject) {
BSONObjBuilder out;
ASSERT_THROWS_CODE(
CollationIndexKey::collationAwareIndexKeyAppend(dataObj.firstElement(), &collator, &out),
- UserException,
+ AssertionException,
ErrorCodes::CannotBuildIndexKeys);
}
@@ -185,7 +185,7 @@ TEST(CollationIndexKeyTest, CollationAwareAppendThrowsIfSymbolInsideArray) {
BSONObjBuilder out;
ASSERT_THROWS_CODE(
CollationIndexKey::collationAwareIndexKeyAppend(dataObj.firstElement(), &collator, &out),
- UserException,
+ AssertionException,
ErrorCodes::CannotBuildIndexKeys);
}
diff --git a/src/mongo/db/query/datetime/date_time_support.h b/src/mongo/db/query/datetime/date_time_support.h
index ddfd32853bc..209c739d1c4 100644
--- a/src/mongo/db/query/datetime/date_time_support.h
+++ b/src/mongo/db/query/datetime/date_time_support.h
@@ -364,7 +364,7 @@ public:
* 'dateString' may contain time zone information if the information is simply an offset from
* UTC, in which case the returned Date_t will be adjusted accordingly.
*
- * Throws a UserException if any of the following occur:
+ * Throws a AssertionException if any of the following occur:
* * The string cannot be parsed into a date.
* * The string specifies a time zone that is not simply an offset from UTC, like
* in the string "July 4, 2017 America/New_York".
diff --git a/src/mongo/db/query/datetime/date_time_support_test.cpp b/src/mongo/db/query/datetime/date_time_support_test.cpp
index c6403154da3..c653a076a0c 100644
--- a/src/mongo/db/query/datetime/date_time_support_test.cpp
+++ b/src/mongo/db/query/datetime/date_time_support_test.cpp
@@ -94,25 +94,25 @@ TEST(GetTimeZone, DoesParseHourMinuteOffsetWithColon) {
}
TEST(GetTimeZone, DoesNotReturnUnknownTimeZone) {
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("The moon"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("xyz"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("Jupiter"), UserException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("The moon"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("xyz"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("Jupiter"), AssertionException, 40485);
}
TEST(GetTimeZone, ThrowsUserExceptionIfGivenUnparsableUtcOffset) {
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("123"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("1234"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("12345"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("-123"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("-12*34"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("-1:23"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("-12:3"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("+123"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("+12*34"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("+1:23"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("+12:3"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("+0x4"), UserException, 40485);
- ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("-0xa0"), UserException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("123"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("1234"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("12345"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("-123"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("-12*34"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("-1:23"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("-12:3"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("+123"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("+12*34"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("+1:23"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("+12:3"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("+0x4"), AssertionException, 40485);
+ ASSERT_THROWS_CODE(kDefaultTimeZoneDatabase.getTimeZone("-0xa0"), AssertionException, 40485);
}
TEST(UTCTimeBeforeEpoch, DoesExtractDateParts) {
@@ -939,21 +939,22 @@ TEST(NewYorkTimeAfterEpoch, DoesOutputFormatDate) {
}
TEST(DateFormat, ThrowsUserExceptionIfGivenUnrecognizedFormatter) {
- ASSERT_THROWS_CODE(TimeZoneDatabase::utcZone().validateFormat("%x"), UserException, 18536);
+ ASSERT_THROWS_CODE(TimeZoneDatabase::utcZone().validateFormat("%x"), AssertionException, 18536);
}
TEST(DateFormat, ThrowsUserExceptionIfGivenUnmatchedPercent) {
- ASSERT_THROWS_CODE(TimeZoneDatabase::utcZone().validateFormat("%"), UserException, 18535);
- ASSERT_THROWS_CODE(TimeZoneDatabase::utcZone().validateFormat("%%%"), UserException, 18535);
+ ASSERT_THROWS_CODE(TimeZoneDatabase::utcZone().validateFormat("%"), AssertionException, 18535);
ASSERT_THROWS_CODE(
- TimeZoneDatabase::utcZone().validateFormat("blahblah%"), UserException, 18535);
+ TimeZoneDatabase::utcZone().validateFormat("%%%"), AssertionException, 18535);
+ ASSERT_THROWS_CODE(
+ TimeZoneDatabase::utcZone().validateFormat("blahblah%"), AssertionException, 18535);
}
TEST(DateFormat, ThrowsUserExceptionIfGivenDateBeforeYear0) {
const long long kMillisPerYear = 31556926000;
ASSERT_THROWS_CODE(TimeZoneDatabase::utcZone().formatDate(
"%Y", Date_t::fromMillisSinceEpoch(-(kMillisPerYear * 1971))),
- UserException,
+ AssertionException,
18537);
ASSERT_EQ("0000",
TimeZoneDatabase::utcZone().formatDate(
@@ -962,7 +963,7 @@ TEST(DateFormat, ThrowsUserExceptionIfGivenDateBeforeYear0) {
TEST(DateFormat, ThrowsUserExceptionIfGivenDateAfterYear9999) {
ASSERT_THROWS_CODE(
- TimeZoneDatabase::utcZone().formatDate("%Y", Date_t::max()), UserException, 18537);
+ TimeZoneDatabase::utcZone().formatDate("%Y", Date_t::max()), AssertionException, 18537);
}
} // namespace
diff --git a/src/mongo/db/repl/abstract_async_component_test.cpp b/src/mongo/db/repl/abstract_async_component_test.cpp
index 9d82755bafd..db0571fc940 100644
--- a/src/mongo/db/repl/abstract_async_component_test.cpp
+++ b/src/mongo/db/repl/abstract_async_component_test.cpp
@@ -181,7 +181,7 @@ void AbstractAsyncComponentTest::tearDown() {
TEST_F(AbstractAsyncComponentTest, ConstructorThrowsUserAssertionOnNullTaskExecutor) {
ASSERT_THROWS_CODE_AND_WHAT(MockAsyncComponent(nullptr),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"task executor cannot be null");
}
diff --git a/src/mongo/db/repl/collection_cloner_test.cpp b/src/mongo/db/repl/collection_cloner_test.cpp
index d3e8966a304..bca11a5e03a 100644
--- a/src/mongo/db/repl/collection_cloner_test.cpp
+++ b/src/mongo/db/repl/collection_cloner_test.cpp
@@ -138,7 +138,7 @@ TEST_F(CollectionClonerTest, InvalidConstruction) {
si,
defaultBatchSize,
defaultNumCloningCursors),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"task executor cannot be null");
}
@@ -153,7 +153,7 @@ TEST_F(CollectionClonerTest, InvalidConstruction) {
nullptr,
defaultBatchSize,
defaultNumCloningCursors),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"storage interface cannot be null");
@@ -170,7 +170,7 @@ TEST_F(CollectionClonerTest, InvalidConstruction) {
si,
defaultBatchSize,
defaultNumCloningCursors),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"invalid collection namespace: db.");
}
@@ -191,7 +191,7 @@ TEST_F(CollectionClonerTest, InvalidConstruction) {
si,
defaultBatchSize,
defaultNumCloningCursors),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"'storageEngine.storageEngine1' has to be an embedded document.");
}
@@ -209,7 +209,7 @@ TEST_F(CollectionClonerTest, InvalidConstruction) {
si,
defaultBatchSize,
defaultNumCloningCursors),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"callback function cannot be null");
}
diff --git a/src/mongo/db/repl/database_cloner.cpp b/src/mongo/db/repl/database_cloner.cpp
index bc7ea109918..f6b3cc030ba 100644
--- a/src/mongo/db/repl/database_cloner.cpp
+++ b/src/mongo/db/repl/database_cloner.cpp
@@ -369,7 +369,7 @@ void DatabaseCloner::_listCollectionsCallback(const StatusWith<Fetcher::QueryRes
_storageInterface,
collectionClonerBatchSize,
maxNumInitialSyncCollectionClonerCursors.load());
- } catch (const UserException& ex) {
+ } catch (const AssertionException& ex) {
_finishCallback_inlock(lk, ex.toStatus());
return;
}
diff --git a/src/mongo/db/repl/database_cloner_test.cpp b/src/mongo/db/repl/database_cloner_test.cpp
index 593090f9ae0..d586221398c 100644
--- a/src/mongo/db/repl/database_cloner_test.cpp
+++ b/src/mongo/db/repl/database_cloner_test.cpp
@@ -136,21 +136,21 @@ TEST_F(DatabaseClonerTest, InvalidConstruction) {
// Null executor -- error from Fetcher, not _databaseCloner.
ASSERT_THROWS_CODE_AND_WHAT(
DatabaseCloner(nullptr, dbWorkThreadPool.get(), target, dbname, filter, pred, si, ccb, cb),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"task executor cannot be null");
// Null db worker thread pool.
ASSERT_THROWS_CODE_AND_WHAT(
DatabaseCloner(&executor, nullptr, target, dbname, filter, pred, si, ccb, cb),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"db worker thread pool cannot be null");
// Empty database name -- error from Fetcher, not _databaseCloner.
ASSERT_THROWS_CODE_AND_WHAT(
DatabaseCloner(&executor, dbWorkThreadPool.get(), target, "", filter, pred, si, ccb, cb),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"database name in remote command request cannot be empty");
@@ -158,7 +158,7 @@ TEST_F(DatabaseClonerTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
DatabaseCloner(
&executor, dbWorkThreadPool.get(), target, dbname, filter, pred, si, ccb, nullptr),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"callback function cannot be null");
@@ -166,7 +166,7 @@ TEST_F(DatabaseClonerTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
DatabaseCloner(
&executor, dbWorkThreadPool.get(), target, dbname, filter, pred, nullptr, ccb, cb),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"storage interface cannot be null");
@@ -174,7 +174,7 @@ TEST_F(DatabaseClonerTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
DatabaseCloner(
&executor, dbWorkThreadPool.get(), target, dbname, filter, pred, si, nullptr, cb),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"collection callback function cannot be null");
@@ -182,7 +182,7 @@ TEST_F(DatabaseClonerTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
DatabaseCloner(
&executor, dbWorkThreadPool.get(), target, dbname, filter, pred, si, ccb, nullptr),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"callback function cannot be null");
}
diff --git a/src/mongo/db/repl/databases_cloner_test.cpp b/src/mongo/db/repl/databases_cloner_test.cpp
index 533198f9e66..58664a44907 100644
--- a/src/mongo/db/repl/databases_cloner_test.cpp
+++ b/src/mongo/db/repl/databases_cloner_test.cpp
@@ -352,7 +352,7 @@ TEST_F(DBsClonerTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
DatabasesCloner(
nullptr, &getExecutor(), &getDbWorkThreadPool(), source, includeDbPred, finishFn),
- UserException,
+ AssertionException,
ErrorCodes::InvalidOptions,
"storage interface must be provided.");
@@ -360,14 +360,14 @@ TEST_F(DBsClonerTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
DatabasesCloner(
&getStorage(), nullptr, &getDbWorkThreadPool(), source, includeDbPred, finishFn),
- UserException,
+ AssertionException,
ErrorCodes::InvalidOptions,
"executor must be provided.");
// Null db worker thread pool.
ASSERT_THROWS_CODE_AND_WHAT(
DatabasesCloner(&getStorage(), &getExecutor(), nullptr, source, includeDbPred, finishFn),
- UserException,
+ AssertionException,
ErrorCodes::InvalidOptions,
"db worker thread pool must be provided.");
@@ -375,7 +375,7 @@ TEST_F(DBsClonerTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
DatabasesCloner(
&getStorage(), &getExecutor(), &getDbWorkThreadPool(), {}, includeDbPred, finishFn),
- UserException,
+ AssertionException,
ErrorCodes::InvalidOptions,
"source must be provided.");
@@ -383,7 +383,7 @@ TEST_F(DBsClonerTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
DatabasesCloner(
&getStorage(), &getExecutor(), &getDbWorkThreadPool(), source, {}, finishFn),
- UserException,
+ AssertionException,
ErrorCodes::InvalidOptions,
"includeDbPred must be provided.");
@@ -391,7 +391,7 @@ TEST_F(DBsClonerTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
DatabasesCloner(
&getStorage(), &getExecutor(), &getDbWorkThreadPool(), source, includeDbPred, {}),
- UserException,
+ AssertionException,
ErrorCodes::InvalidOptions,
"finishFn must be provided.");
}
diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp
index 033af4a4ad6..dbc94f0095e 100644
--- a/src/mongo/db/repl/initial_syncer_test.cpp
+++ b/src/mongo/db/repl/initial_syncer_test.cpp
@@ -542,7 +542,7 @@ TEST_F(InitialSyncerTest, InvalidConstruction) {
_storageInterface.get(),
_replicationProcess.get(),
callback),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"task executor cannot be null");
}
@@ -556,7 +556,7 @@ TEST_F(InitialSyncerTest, InvalidConstruction) {
_storageInterface.get(),
_replicationProcess.get(),
InitialSyncer::OnCompletionFn()),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"callback function cannot be null");
}
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp
index 1567d6dc603..da01612154e 100644
--- a/src/mongo/db/repl/master_slave.cpp
+++ b/src/mongo/db/repl/master_slave.cpp
@@ -646,7 +646,7 @@ void ReplSource::applyCommand(OperationContext* opCtx, const BSONObj& op) {
try {
Status status = applyCommand_inlock(opCtx, op, true);
uassert(28639, "Failure applying initial sync command", status.isOK());
- } catch (UserException& e) {
+ } catch (AssertionException& e) {
log() << "sync: caught user assertion " << redact(e) << " while applying op: " << redact(op)
<< endl;
;
@@ -673,7 +673,7 @@ void ReplSource::applyOperation(OperationContext* opCtx, Database* db, const BSO
sync.setHostname(hostName);
sync.fetchAndInsertMissingDocument(opCtx, op);
}
- } catch (UserException& e) {
+ } catch (AssertionException& e) {
log() << "sync: caught user assertion " << redact(e) << " while applying op: " << redact(op)
<< endl;
;
@@ -1209,14 +1209,6 @@ int _replMain(OperationContext* opCtx, ReplSource::SourceVector& sources, int& n
} catch (const SyncException&) {
log() << "caught SyncException" << endl;
return 10;
- } catch (AssertionException& e) {
- if (e.severe()) {
- log() << "replMain AssertionException " << redact(e) << endl;
- return 60;
- } else {
- log() << "AssertionException " << redact(e) << endl;
- }
- replInfo = "replMain caught AssertionException";
} catch (const DBException& e) {
log() << "DBException " << redact(e) << endl;
replInfo = "replMain caught DBException";
diff --git a/src/mongo/db/repl/multiapplier_test.cpp b/src/mongo/db/repl/multiapplier_test.cpp
index a031064130b..95e737bac0e 100644
--- a/src/mongo/db/repl/multiapplier_test.cpp
+++ b/src/mongo/db/repl/multiapplier_test.cpp
@@ -83,7 +83,7 @@ TEST_F(MultiApplierTest, InvalidConstruction) {
// Null executor.
ASSERT_THROWS_CODE_AND_WHAT(
MultiApplier(nullptr, operations, applyOperation, multiApply, callback),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"null replication executor");
@@ -91,7 +91,7 @@ TEST_F(MultiApplierTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
MultiApplier(
&getExecutor(), MultiApplier::Operations(), applyOperation, multiApply, callback),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"empty list of operations");
@@ -99,7 +99,7 @@ TEST_F(MultiApplierTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
MultiApplier(
&getExecutor(), operations, MultiApplier::ApplyOperationFn(), multiApply, callback),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"apply operation function cannot be null");
@@ -107,7 +107,7 @@ TEST_F(MultiApplierTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
MultiApplier(
&getExecutor(), operations, applyOperation, MultiApplier::MultiApplyFn(), callback),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"multi apply function cannot be null");
@@ -115,7 +115,7 @@ TEST_F(MultiApplierTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
MultiApplier(
&getExecutor(), operations, applyOperation, multiApply, MultiApplier::CallbackFn()),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"callback function cannot be null");
}
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 0e7f873fcfd..e7e6de49b11 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -571,7 +571,7 @@ void createOplog(OperationContext* opCtx, const std::string& oplogCollectionName
ss << "cmdline oplogsize (" << n << ") different than existing (" << o
<< ") see: http://dochub.mongodb.org/core/increase-oplog";
log() << ss.str() << endl;
- throw UserException(13257, ss.str());
+ throw AssertionException(13257, ss.str());
}
}
@@ -1134,7 +1134,7 @@ Status applyOperation_inlock(OperationContext* opCtx,
}
} else {
invariant(*opType != 'c'); // commands are processed in applyCommand_inlock()
- throw MsgAssertionException(
+ throw AssertionException(
14825, str::stream() << "error in applyOperation : unknown opType " << *opType);
}
diff --git a/src/mongo/db/repl/reporter_test.cpp b/src/mongo/db/repl/reporter_test.cpp
index f0261d64f5f..97485f030e5 100644
--- a/src/mongo/db/repl/reporter_test.cpp
+++ b/src/mongo/db/repl/reporter_test.cpp
@@ -248,13 +248,13 @@ TEST_F(ReporterTestNoTriggerAtSetUp, InvalidConstruction) {
Reporter::PrepareReplSetUpdatePositionCommandFn(),
HostAndPort("h1"),
Milliseconds(1000)),
- UserException);
+ AssertionException);
// null TaskExecutor
ASSERT_THROWS_WHAT(
Reporter(
nullptr, prepareReplSetUpdatePositionCommandFn, HostAndPort("h1"), Milliseconds(1000)),
- UserException,
+ AssertionException,
"null task executor");
// null PrepareReplSetUpdatePositionCommandFn
@@ -262,7 +262,7 @@ TEST_F(ReporterTestNoTriggerAtSetUp, InvalidConstruction) {
Reporter::PrepareReplSetUpdatePositionCommandFn(),
HostAndPort("h1"),
Milliseconds(1000)),
- UserException,
+ AssertionException,
"null function to create replSetUpdatePosition command object");
// empty HostAndPort
@@ -270,21 +270,21 @@ TEST_F(ReporterTestNoTriggerAtSetUp, InvalidConstruction) {
prepareReplSetUpdatePositionCommandFn,
HostAndPort(),
Milliseconds(1000)),
- UserException,
+ AssertionException,
"target name cannot be empty");
// zero keep alive interval.
ASSERT_THROWS_WHAT(
Reporter(
&getExecutor(), prepareReplSetUpdatePositionCommandFn, HostAndPort("h1"), Seconds(-1)),
- UserException,
+ AssertionException,
"keep alive interval must be positive");
// negative keep alive interval.
ASSERT_THROWS_WHAT(
Reporter(
&getExecutor(), prepareReplSetUpdatePositionCommandFn, HostAndPort("h1"), Seconds(-1)),
- UserException,
+ AssertionException,
"keep alive interval must be positive");
}
diff --git a/src/mongo/db/repl/roll_back_local_operations_test.cpp b/src/mongo/db/repl/roll_back_local_operations_test.cpp
index 71abee20b72..93f70d07268 100644
--- a/src/mongo/db/repl/roll_back_local_operations_test.cpp
+++ b/src/mongo/db/repl/roll_back_local_operations_test.cpp
@@ -61,14 +61,14 @@ TEST(RollBackLocalOperationsTest, InvalidLocalOplogIterator) {
} invalidOplog;
ASSERT_THROWS_CODE(
RollBackLocalOperations(invalidOplog, [](const BSONObj&) { return Status::OK(); }),
- UserException,
+ AssertionException,
ErrorCodes::BadValue);
}
TEST(RollBackLocalOperationsTest, InvalidRollbackOperationFunction) {
ASSERT_THROWS_CODE(RollBackLocalOperations(OplogInterfaceMock({makeOpAndRecordId(1, 0)}),
RollBackLocalOperations::RollbackOperationFn()),
- UserException,
+ AssertionException,
ErrorCodes::BadValue);
}
diff --git a/src/mongo/db/repl/rollback_checker_test.cpp b/src/mongo/db/repl/rollback_checker_test.cpp
index 985a0f59a96..3f9ae14266c 100644
--- a/src/mongo/db/repl/rollback_checker_test.cpp
+++ b/src/mongo/db/repl/rollback_checker_test.cpp
@@ -78,7 +78,8 @@ TEST_F(RollbackCheckerTest, InvalidConstruction) {
HostAndPort syncSource;
// Null executor.
- ASSERT_THROWS_CODE(RollbackChecker(nullptr, syncSource), UserException, ErrorCodes::BadValue);
+ ASSERT_THROWS_CODE(
+ RollbackChecker(nullptr, syncSource), AssertionException, ErrorCodes::BadValue);
}
TEST_F(RollbackCheckerTest, ShutdownBeforeStart) {
diff --git a/src/mongo/db/repl/rs_rollback_no_uuid_test.cpp b/src/mongo/db/repl/rs_rollback_no_uuid_test.cpp
index 8107507d487..2b4f239c54c 100644
--- a/src/mongo/db/repl/rs_rollback_no_uuid_test.cpp
+++ b/src/mongo/db/repl/rs_rollback_no_uuid_test.cpp
@@ -212,7 +212,7 @@ TEST_F(RSRollbackTest, RemoteGetRollbackIdThrows) {
_coordinator,
_replicationProcess.get())
.transitional_ignore(),
- UserException,
+ AssertionException,
ErrorCodes::UnknownError);
}
@@ -237,7 +237,7 @@ TEST_F(RSRollbackTest, RemoteGetRollbackIdDiffersFromRequiredRBID) {
_coordinator,
_replicationProcess.get())
.transitional_ignore(),
- UserException,
+ AssertionException,
ErrorCodes::Error(40362));
}
diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp
index 99f18f723ea..6555843ad26 100644
--- a/src/mongo/db/repl/rs_rollback_test.cpp
+++ b/src/mongo/db/repl/rs_rollback_test.cpp
@@ -300,7 +300,7 @@ TEST_F(RSRollbackTest, RemoteGetRollbackIdThrows) {
_coordinator,
_replicationProcess.get())
.transitional_ignore(),
- UserException,
+ AssertionException,
ErrorCodes::UnknownError);
}
@@ -324,7 +324,7 @@ TEST_F(RSRollbackTest, RemoteGetRollbackIdDiffersFromRequiredRBID) {
_coordinator,
_replicationProcess.get())
.transitional_ignore(),
- UserException,
+ AssertionException,
ErrorCodes::Error(40506));
}
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index 3b0059f9c04..f532e5aa361 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -392,7 +392,7 @@ Status StorageInterfaceImpl::createCollection(OperationContext* opCtx,
try {
auto coll = db->createCollection(opCtx, nss.ns(), options);
invariant(coll);
- } catch (const UserException& ex) {
+ } catch (const AssertionException& ex) {
return ex.toStatus();
}
wuow.commit();
diff --git a/src/mongo/db/repl/storage_interface_impl_test.cpp b/src/mongo/db/repl/storage_interface_impl_test.cpp
index acea2cd4571..5e6ba445814 100644
--- a/src/mongo/db/repl/storage_interface_impl_test.cpp
+++ b/src/mongo/db/repl/storage_interface_impl_test.cpp
@@ -1908,7 +1908,7 @@ TEST_F(StorageInterfaceImplTest,
BSON("" << 1).firstElement(),
BSON("$unknownUpdateOp" << BSON("x" << 1000)))
.transitional_ignore(),
- UserException,
+ AssertionException,
ErrorCodes::FailedToParse,
"Unknown modifier: $unknownUpdateOp");
}
diff --git a/src/mongo/db/repl/sync_source_resolver_test.cpp b/src/mongo/db/repl/sync_source_resolver_test.cpp
index 48bdf70f13c..77154e62ae6 100644
--- a/src/mongo/db/repl/sync_source_resolver_test.cpp
+++ b/src/mongo/db/repl/sync_source_resolver_test.cpp
@@ -158,7 +158,7 @@ TEST_F(SyncSourceResolverTest, InvalidConstruction) {
// Null task executor.
ASSERT_THROWS_CODE_AND_WHAT(
SyncSourceResolver(nullptr, &selector, lastOpTimeFetched, requiredOpTime, onCompletion),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"task executor cannot be null");
@@ -166,14 +166,14 @@ TEST_F(SyncSourceResolverTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
SyncSourceResolver(
&getExecutor(), nullptr, lastOpTimeFetched, requiredOpTime, onCompletion),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"sync source selector cannot be null");
// Null last fetched optime.
ASSERT_THROWS_CODE_AND_WHAT(
SyncSourceResolver(&getExecutor(), &selector, OpTime(), requiredOpTime, onCompletion),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"last fetched optime cannot be null");
@@ -183,7 +183,7 @@ TEST_F(SyncSourceResolverTest, InvalidConstruction) {
lastOpTimeFetched,
OpTime(Timestamp(Seconds(50), 1U), 1LL),
onCompletion),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"required optime (if provided) must be more recent than last "
"fetched optime. requiredOpTime: { ts: Timestamp 50000|1, t: 1 }, "
@@ -191,7 +191,7 @@ TEST_F(SyncSourceResolverTest, InvalidConstruction) {
ASSERT_THROWS_CODE_AND_WHAT(
SyncSourceResolver(
&getExecutor(), &selector, lastOpTimeFetched, lastOpTimeFetched, onCompletion),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"required optime (if provided) must be more recent than last fetched optime. "
"requiredOpTime: { ts: Timestamp 100000|1, t: 1 }, lastOpTimeFetched: { ts: Timestamp "
@@ -203,7 +203,7 @@ TEST_F(SyncSourceResolverTest, InvalidConstruction) {
lastOpTimeFetched,
requiredOpTime,
SyncSourceResolver::OnCompletionFn()),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"callback function cannot be null");
}
diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp
index 37d85269b96..b34d74bec32 100644
--- a/src/mongo/db/repl/sync_tail_test.cpp
+++ b/src/mongo/db/repl/sync_tail_test.cpp
@@ -218,8 +218,9 @@ TEST_F(SyncTailTest, SyncApplyNoOpApplyOpThrowsException) {
}
TEST_F(SyncTailTest, SyncApplyInsertDocumentDatabaseMissing) {
- ASSERT_THROWS_CODE(
- _testSyncApplyInsertDocument(ErrorCodes::OK), UserException, ErrorCodes::NamespaceNotFound);
+ ASSERT_THROWS_CODE(_testSyncApplyInsertDocument(ErrorCodes::OK),
+ AssertionException,
+ ErrorCodes::NamespaceNotFound);
}
TEST_F(SyncTailTest, SyncApplyInsertDocumentCollectionMissing) {
diff --git a/src/mongo/db/repl/task_runner_test.cpp b/src/mongo/db/repl/task_runner_test.cpp
index 62b64513b37..d2f9d3440e0 100644
--- a/src/mongo/db/repl/task_runner_test.cpp
+++ b/src/mongo/db/repl/task_runner_test.cpp
@@ -48,7 +48,7 @@ using Task = TaskRunner::Task;
TEST_F(TaskRunnerTest, InvalidConstruction) {
// Null thread pool.
ASSERT_THROWS_CODE_AND_WHAT(
- TaskRunner(nullptr), UserException, ErrorCodes::BadValue, "null thread pool");
+ TaskRunner(nullptr), AssertionException, ErrorCodes::BadValue, "null thread pool");
}
TEST_F(TaskRunnerTest, GetDiagnosticString) {
diff --git a/src/mongo/db/s/namespace_metadata_change_notifications_test.cpp b/src/mongo/db/s/namespace_metadata_change_notifications_test.cpp
index 66b4e28c33b..155eed7cae3 100644
--- a/src/mongo/db/s/namespace_metadata_change_notifications_test.cpp
+++ b/src/mongo/db/s/namespace_metadata_change_notifications_test.cpp
@@ -69,7 +69,7 @@ TEST_F(NamespaceMetadataChangeNotificationsTest, WaitForNotify) {
auto opCtx = client()->makeOperationContext();
opCtx->setDeadlineAfterNowBy(Milliseconds{0});
ASSERT_THROWS_CODE(
- scopedNotif.get(opCtx.get()), UserException, ErrorCodes::ExceededTimeLimit);
+ scopedNotif.get(opCtx.get()), AssertionException, ErrorCodes::ExceededTimeLimit);
}
notifications.notifyChange(kNss);
@@ -89,7 +89,7 @@ TEST_F(NamespaceMetadataChangeNotificationsTest, GiveUpWaitingForNotify) {
auto opCtx = client()->makeOperationContext();
opCtx->setDeadlineAfterNowBy(Milliseconds{0});
ASSERT_THROWS_CODE(
- scopedNotif.get(opCtx.get()), UserException, ErrorCodes::ExceededTimeLimit);
+ scopedNotif.get(opCtx.get()), AssertionException, ErrorCodes::ExceededTimeLimit);
}
notifications.notifyChange(kNss);
@@ -105,7 +105,7 @@ TEST_F(NamespaceMetadataChangeNotificationsTest, MoveConstructionWaitForNotify)
auto opCtx = client()->makeOperationContext();
opCtx->setDeadlineAfterNowBy(Milliseconds{0});
ASSERT_THROWS_CODE(
- movedScopedNotif.get(opCtx.get()), UserException, ErrorCodes::ExceededTimeLimit);
+ movedScopedNotif.get(opCtx.get()), AssertionException, ErrorCodes::ExceededTimeLimit);
}
notifications.notifyChange(kNss);
diff --git a/src/mongo/db/s/type_shard_identity.cpp b/src/mongo/db/s/type_shard_identity.cpp
index 089b2046080..c94fa6e5892 100644
--- a/src/mongo/db/s/type_shard_identity.cpp
+++ b/src/mongo/db/s/type_shard_identity.cpp
@@ -86,7 +86,7 @@ StatusWith<ShardIdentityType> ShardIdentityType::fromBSON(const BSONObj& source)
}
shardIdentity.setConfigsvrConnString(std::move(configSvrConnStr));
- } catch (const UserException& parseException) {
+ } catch (const AssertionException& parseException) {
return parseException.toStatus();
}
}
diff --git a/src/mongo/db/service_entry_point_mongod.cpp b/src/mongo/db/service_entry_point_mongod.cpp
index 6b49b026d5f..491a61dc9ea 100644
--- a/src/mongo/db/service_entry_point_mongod.cpp
+++ b/src/mongo/db/service_entry_point_mongod.cpp
@@ -1106,17 +1106,11 @@ DbResponse ServiceEntryPointMongod::handleRequest(OperationContext* opCtx, const
invariant(false);
}
}
- } catch (const UserException& ue) {
+ } catch (const AssertionException& ue) {
LastError::get(c).setLastError(ue.code(), ue.reason());
LOG(3) << " Caught Assertion in " << networkOpToString(op) << ", continuing "
<< redact(ue);
debug.exceptionInfo = ue.toStatus();
- } catch (const AssertionException& e) {
- LastError::get(c).setLastError(e.code(), e.reason());
- LOG(3) << " Caught Assertion in " << networkOpToString(op) << ", continuing "
- << redact(e);
- debug.exceptionInfo = e.toStatus();
- shouldLogOpDebug = true;
}
}
currentOp.ensureStarted();
diff --git a/src/mongo/db/session_test.cpp b/src/mongo/db/session_test.cpp
index 2d3d72eafa1..0170a9f03fd 100644
--- a/src/mongo/db/session_test.cpp
+++ b/src/mongo/db/session_test.cpp
@@ -147,7 +147,7 @@ TEST_F(SessionTest, StartingOldTxnShouldAssert) {
Session txnState(sessionId);
txnState.begin(opCtx(), txnNum);
- ASSERT_THROWS(txnState.begin(opCtx(), txnNum - 1), UserException);
+ ASSERT_THROWS(txnState.begin(opCtx(), txnNum - 1), AssertionException);
ASSERT_EQ(sessionId, txnState.getSessionId());
ASSERT_EQ(txnNum, txnState.getTxnNum());
ASSERT_TRUE(txnState.getLastWriteOpTimeTs().isNull());
@@ -245,7 +245,7 @@ TEST_F(SessionTest, StartingNewSessionWithNewerEntryInStorageShouldAssert) {
client.insert(NamespaceString::kSessionTransactionsTableNamespace.ns(), origRecord.toBSON());
Session txnState(sessionId);
- ASSERT_THROWS(txnState.begin(opCtx(), txnNum - 1), UserException);
+ ASSERT_THROWS(txnState.begin(opCtx(), txnNum - 1), AssertionException);
ASSERT_EQ(sessionId, txnState.getSessionId());
ASSERT_EQ(txnNum, txnState.getTxnNum());
@@ -407,7 +407,7 @@ TEST_F(SessionTest, StartingNewSessionWithDroppedTableShouldAssert) {
ASSERT_TRUE(client.runCommand(ns.db().toString(), BSON("drop" << ns.coll()), dropResult));
Session txnState(sessionId);
- ASSERT_THROWS(txnState.begin(opCtx(), txnNum), UserException);
+ ASSERT_THROWS(txnState.begin(opCtx(), txnNum), AssertionException);
ASSERT_EQ(sessionId, txnState.getSessionId());
}
@@ -429,7 +429,7 @@ TEST_F(SessionTest, SaveTxnProgressShouldAssertIfTableIsDropped) {
AutoGetCollection autoColl(opCtx(), NamespaceString("test.user"), MODE_IX);
WriteUnitOfWork wuow(opCtx());
- ASSERT_THROWS(txnState.saveTxnProgress(opCtx(), ts1), UserException);
+ ASSERT_THROWS(txnState.saveTxnProgress(opCtx(), ts1), AssertionException);
}
TEST_F(SessionTest, TwoSessionsShouldBeIndependent) {
@@ -604,7 +604,7 @@ TEST_F(SessionTest, StartingOldTxnFailsAfterReset) {
Session::updateSessionRecord(opCtx(), sessionId, newTxnNum, Timestamp());
txnState.reset();
- ASSERT_THROWS(txnState.begin(opCtx(), oldTxnNum), UserException);
+ ASSERT_THROWS(txnState.begin(opCtx(), oldTxnNum), AssertionException);
}
TEST_F(SessionTest, CanStartLaterTxnAfterReset) {
diff --git a/src/mongo/db/storage/kv/kv_engine_test_snapshots.cpp b/src/mongo/db/storage/kv/kv_engine_test_snapshots.cpp
index 932fb0b70c7..be9bcb80fc7 100644
--- a/src/mongo/db/storage/kv/kv_engine_test_snapshots.cpp
+++ b/src/mongo/db/storage/kv/kv_engine_test_snapshots.cpp
@@ -249,7 +249,7 @@ TEST_F(SnapshotManagerTests, FailsAfterDropAllSnapshotsWhileYielded) {
// Now it doesn't.
op->recoveryUnit()->abandonSnapshot();
ASSERT_THROWS_CODE(
- itCountOn(op), UserException, ErrorCodes::ReadConcernMajorityNotAvailableYet);
+ itCountOn(op), AssertionException, ErrorCodes::ReadConcernMajorityNotAvailableYet);
}
TEST_F(SnapshotManagerTests, BasicFunctionality) {
diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp
index 293fa482c41..78bda18e878 100644
--- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp
+++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp
@@ -94,7 +94,7 @@ NamespaceDetails::Extra* NamespaceDetails::allocExtra(OperationContext* opCtx,
verify(i >= 0 && i <= 1);
Namespace fullns(ns);
- Namespace extrans(fullns.extraName(i)); // throws UserException if ns name too long
+ Namespace extrans(fullns.extraName(i)); // throws AssertionException if ns name too long
massert(10351, "allocExtra: extra already exists", ni.details(extrans) == 0);
@@ -125,7 +125,7 @@ IndexDetails& NamespaceDetails::idx(int idxNo, bool missingExpected) {
Extra* e = extra();
if (!e) {
if (missingExpected)
- throw MsgAssertionException(13283, "Missing Extra");
+ throw AssertionException(13283, "Missing Extra");
massert(14045, "missing Extra", e);
}
int i = idxNo - NIndexesBase;
@@ -133,7 +133,7 @@ IndexDetails& NamespaceDetails::idx(int idxNo, bool missingExpected) {
e = e->next(this);
if (!e) {
if (missingExpected)
- throw MsgAssertionException(14823, "missing extra");
+ throw AssertionException(14823, "missing extra");
massert(14824, "missing Extra", e);
}
i -= NIndexesExtra;
@@ -150,7 +150,7 @@ const IndexDetails& NamespaceDetails::idx(int idxNo, bool missingExpected) const
const Extra* e = extra();
if (!e) {
if (missingExpected)
- throw MsgAssertionException(17421, "Missing Extra");
+ throw AssertionException(17421, "Missing Extra");
massert(17422, "missing Extra", e);
}
int i = idxNo - NIndexesBase;
@@ -158,7 +158,7 @@ const IndexDetails& NamespaceDetails::idx(int idxNo, bool missingExpected) const
e = e->next(this);
if (!e) {
if (missingExpected)
- throw MsgAssertionException(17423, "missing extra");
+ throw AssertionException(17423, "missing extra");
massert(17424, "missing Extra", e);
}
i -= NIndexesExtra;
diff --git a/src/mongo/db/storage/mmap_v1/dur_journal.cpp b/src/mongo/db/storage/mmap_v1/dur_journal.cpp
index a74e87b5e6e..364948e3226 100644
--- a/src/mongo/db/storage/mmap_v1/dur_journal.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur_journal.cpp
@@ -417,7 +417,7 @@ void checkFreeSpace() {
log() << "Please make at least " << spaceNeeded / (1024 * 1024) << "MB available in "
<< getJournalDir().string() << " or use --smallfiles" << endl;
log() << endl;
- throw UserException(15926, "Insufficient free space for journals");
+ throw AssertionException(15926, "Insufficient free space for journals");
}
}
diff --git a/src/mongo/db/storage/recovery_unit.h b/src/mongo/db/storage/recovery_unit.h
index e7741936544..3baa174dcbc 100644
--- a/src/mongo/db/storage/recovery_unit.h
+++ b/src/mongo/db/storage/recovery_unit.h
@@ -90,11 +90,11 @@ public:
* committed snapshots should be used if available whenever implementations would normally
* change snapshots.
*
- * If no snapshot has yet been marked as Majority Committed, returns a status with error
- * code ReadConcernMajorityNotAvailableYet. After this returns successfully, at any point where
+ * If no snapshot has yet been marked as Majority Committed, returns a status with error code
+ * ReadConcernMajorityNotAvailableYet. After this returns successfully, at any point where
* implementations attempt to acquire committed snapshot, if there are none available due to a
- * call to SnapshotManager::dropAllSnapshots(), a UserException with the same code should be
- * thrown.
+ * call to SnapshotManager::dropAllSnapshots(), a AssertionException with the same code should
+ * be thrown.
*
* StorageEngines that don't support a SnapshotManager should use the default
* implementation.
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
index cf6a6f96be8..2fd8b424604 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
@@ -112,7 +112,7 @@ public:
const bool forceCheckpoint = false;
const bool stableCheckpoint = false;
_sessionCache->waitUntilDurable(forceCheckpoint, stableCheckpoint);
- } catch (const UserException& e) {
+ } catch (const AssertionException& e) {
invariant(e.code() == ErrorCodes::ShutdownInProgress);
}
@@ -201,7 +201,7 @@ public:
_sessionCache->waitUntilDurable(forceCheckpoint, stableCheckpoint);
}
}
- } catch (const UserException& exc) {
+ } catch (const AssertionException& exc) {
invariant(exc.code() == ErrorCodes::ShutdownInProgress);
}
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_parameters.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_parameters.cpp
index d5a74f184ce..dc2ffb0ebb5 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_parameters.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_parameters.cpp
@@ -55,7 +55,7 @@ void WiredTigerEngineRuntimeConfigParameter::append(OperationContext* opCtx,
Status WiredTigerEngineRuntimeConfigParameter::set(const BSONElement& newValueElement) {
try {
return setFromString(newValueElement.String());
- } catch (const MsgAssertionException& msg) {
+ } catch (const AssertionException& msg) {
return Status(
ErrorCodes::BadValue,
mongoutils::str::stream()
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp
index 8f0f862f881..c391836685f 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp
@@ -207,7 +207,7 @@ TEST(WiredTigerRecordStoreTest, StorageSizeStatisticsDisabled) {
unique_ptr<RecordStore> rs(harnessHelper.newNonCappedRecordStore("a.b"));
ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext());
- ASSERT_THROWS(rs->storageSize(opCtx.get()), UserException);
+ ASSERT_THROWS(rs->storageSize(opCtx.get()), AssertionException);
}
TEST(WiredTigerRecordStoreTest, SizeStorer1) {
diff --git a/src/mongo/db/transaction_history_iterator_test.cpp b/src/mongo/db/transaction_history_iterator_test.cpp
index a31b5eb8fa6..18464573f94 100644
--- a/src/mongo/db/transaction_history_iterator_test.cpp
+++ b/src/mongo/db/transaction_history_iterator_test.cpp
@@ -196,7 +196,8 @@ TEST_F(SessionHistoryIteratorTest, NextShouldAssertIfHistoryIsTruncated) {
ASSERT_BSONOBJ_EQ(BSON("y" << 50), nextEntry.getObject());
ASSERT_TRUE(iter.hasNext());
- ASSERT_THROWS_CODE(iter.next(opCtx()), UserException, ErrorCodes::IncompleteTransactionHistory);
+ ASSERT_THROWS_CODE(
+ iter.next(opCtx()), AssertionException, ErrorCodes::IncompleteTransactionHistory);
}
TEST_F(SessionHistoryIteratorTest, OplogInWriteHistoryChainWithMissingPrevTSShouldAssert) {
@@ -209,7 +210,7 @@ TEST_F(SessionHistoryIteratorTest, OplogInWriteHistoryChainWithMissingPrevTSShou
TransactionHistoryIterator iter(Timestamp(67, 54801));
ASSERT_TRUE(iter.hasNext());
- ASSERT_THROWS_CODE(iter.next(opCtx()), UserException, ErrorCodes::FailedToParse);
+ ASSERT_THROWS_CODE(iter.next(opCtx()), AssertionException, ErrorCodes::FailedToParse);
}
} // namespace mongo
diff --git a/src/mongo/db/update/addtoset_node_test.cpp b/src/mongo/db/update/addtoset_node_test.cpp
index c8440764c38..26e6e1ea4fc 100644
--- a/src/mongo/db/update/addtoset_node_test.cpp
+++ b/src/mongo/db/update/addtoset_node_test.cpp
@@ -112,7 +112,7 @@ TEST_F(AddToSetNodeTest, ApplyFailsOnNonArray) {
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"Cannot apply $addToSet to non-array field. Field named 'a' has non-array type int");
}
diff --git a/src/mongo/db/update/arithmetic_node_test.cpp b/src/mongo/db/update/arithmetic_node_test.cpp
index 3a4d74121ea..a0a74654ac0 100644
--- a/src/mongo/db/update/arithmetic_node_test.cpp
+++ b/src/mongo/db/update/arithmetic_node_test.cpp
@@ -258,7 +258,7 @@ TEST_F(ArithmeticNodeTest, ApplyNonViablePathToInc) {
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot create field 'b' in element {a: 5}");
}
@@ -552,7 +552,7 @@ TEST_F(ArithmeticNodeTest, ApplyIncToObjectFails) {
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::TypeMismatch,
"Cannot apply $inc to a value of non-numeric type. {_id: "
"\"test_object\"} has the field 'a' of non-numeric type object");
@@ -568,7 +568,7 @@ TEST_F(ArithmeticNodeTest, ApplyIncToArrayFails) {
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::TypeMismatch,
"Cannot apply $inc to a value of non-numeric type. {_id: "
"\"test_object\"} has the field 'a' of non-numeric type array");
@@ -584,7 +584,7 @@ TEST_F(ArithmeticNodeTest, ApplyIncToStringFails) {
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::TypeMismatch,
"Cannot apply $inc to a value of non-numeric type. {_id: "
"\"test_object\"} has the field 'a' of non-numeric type string");
@@ -663,7 +663,7 @@ TEST_F(ArithmeticNodeTest, ApplyPathNotViableArray) {
setPathToCreate("b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot create field 'b' in element {a: [ { b: 1 } ]}");
}
@@ -775,7 +775,7 @@ TEST_F(ArithmeticNodeTest, ApplyNonViablePathThroughArray) {
setPathToCreate("2.b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot create field '2' in element {a: 0}");
}
diff --git a/src/mongo/db/update/object_replace_node_test.cpp b/src/mongo/db/update/object_replace_node_test.cpp
index 645a3e69ff3..27bb8aea7b3 100644
--- a/src/mongo/db/update/object_replace_node_test.cpp
+++ b/src/mongo/db/update/object_replace_node_test.cpp
@@ -158,7 +158,7 @@ TEST_F(ObjectReplaceNodeTest, CannotRemoveImmutablePath) {
mutablebson::Document doc(fromjson("{_id: 0, a: {b: 1}}"));
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"After applying the update, the 'a.b' (required and immutable) "
"field was found to have been removed --{ _id: 0, a: { b: 1 } }");
@@ -185,7 +185,7 @@ TEST_F(ObjectReplaceNodeTest, CannotReplaceImmutablePathWithArrayField) {
mutablebson::Document doc(fromjson("{_id: 0, a: {b: 1}}"));
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::NotSingleValueField,
"After applying the update to the document, the (immutable) field "
"'a.b' was found to be an array or array descendant.");
@@ -198,7 +198,7 @@ TEST_F(ObjectReplaceNodeTest, CannotMakeImmutablePathArrayDescendant) {
mutablebson::Document doc(fromjson("{_id: 0, a: {'0': 1}}"));
addImmutablePath("a.0");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::NotSingleValueField,
"After applying the update to the document, the (immutable) field "
"'a.0' was found to be an array or array descendant.");
@@ -211,7 +211,7 @@ TEST_F(ObjectReplaceNodeTest, CannotModifyImmutablePath) {
mutablebson::Document doc(fromjson("{_id: 0, a: {b: 1}}"));
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"After applying the update, the (immutable) field 'a.b' was found "
"to have been altered to b: 2");
@@ -224,7 +224,7 @@ TEST_F(ObjectReplaceNodeTest, CannotModifyImmutableId) {
mutablebson::Document doc(fromjson("{_id: 0}"));
addImmutablePath("_id");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"After applying the update, the (immutable) field '_id' was found "
"to have been altered to _id: 1");
@@ -265,7 +265,7 @@ TEST_F(ObjectReplaceNodeTest, CannotCreateDollarPrefixedNameWhenValidateForStora
mutablebson::Document doc(fromjson("{}"));
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::DollarPrefixedFieldName,
"The dollar ($) prefixed field '$bad' in 'a.$bad' is not valid for storage.");
}
diff --git a/src/mongo/db/update/pop_node_test.cpp b/src/mongo/db/update/pop_node_test.cpp
index 4cb14505988..40e0d38c36c 100644
--- a/src/mongo/db/update/pop_node_test.cpp
+++ b/src/mongo/db/update/pop_node_test.cpp
@@ -162,7 +162,7 @@ TEST_F(PopNodeTest, ThrowsWhenPathIsBlockedByAScalar) {
addIndexedPath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
popNode.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot use the part (b) of (a.b) to traverse the element ({a: \"foo\"})");
}
@@ -191,7 +191,7 @@ TEST_F(PopNodeTest, ThrowsWhenPathExistsButDoesNotContainAnArray) {
setPathTaken("a.b");
addIndexedPath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(popNode.apply(getApplyParams(doc.root()["a"]["b"])),
- UserException,
+ AssertionException,
ErrorCodes::TypeMismatch,
"Path 'a.b' contains an element of non-array type 'string'");
}
@@ -342,7 +342,7 @@ TEST_F(PopNodeTest, ThrowsWhenPathIsImmutable) {
addIndexedPath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
popNode.apply(getApplyParams(doc.root()["a"]["b"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Performing a $pop on the path 'a.b' would modify the immutable field 'a.b'");
}
@@ -364,7 +364,7 @@ TEST_F(PopNodeTest, ThrowsWhenPathIsPrefixOfImmutable) {
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(
popNode.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Performing a $pop on the path 'a' would modify the immutable field 'a.0'");
}
@@ -381,7 +381,7 @@ TEST_F(PopNodeTest, ThrowsWhenPathIsSuffixOfImmutable) {
addIndexedPath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
popNode.apply(getApplyParams(doc.root()["a"]["b"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Performing a $pop on the path 'a.b' would modify the immutable field 'a'");
}
diff --git a/src/mongo/db/update/pull_node.cpp b/src/mongo/db/update/pull_node.cpp
index e7a70620ad4..5842718c388 100644
--- a/src/mongo/db/update/pull_node.cpp
+++ b/src/mongo/db/update/pull_node.cpp
@@ -137,7 +137,7 @@ Status PullNode::init(BSONElement modExpr, const CollatorInterface* collator) {
} else {
_matcher = stdx::make_unique<EqualityMatcher>(modExpr, collator);
}
- } catch (UserException& exception) {
+ } catch (AssertionException& exception) {
return exception.toStatus();
}
diff --git a/src/mongo/db/update/pull_node_test.cpp b/src/mongo/db/update/pull_node_test.cpp
index 9d3c101fba9..d54640c0d1a 100644
--- a/src/mongo/db/update/pull_node_test.cpp
+++ b/src/mongo/db/update/pull_node_test.cpp
@@ -90,7 +90,7 @@ TEST_F(PullNodeTest, ApplyToStringFails) {
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"Cannot apply $pull to a non-array value");
}
@@ -105,7 +105,7 @@ TEST_F(PullNodeTest, ApplyToObjectFails) {
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"Cannot apply $pull to a non-array value");
}
@@ -122,7 +122,7 @@ TEST_F(PullNodeTest, ApplyToNonViablePathFails) {
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot use the part (b) of (a.b) to traverse the element ({a: 1})");
}
@@ -580,7 +580,7 @@ TEST_F(PullNodeTest, CannotModifyImmutableField) {
addImmutablePath("_id");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["_id"]["a"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Performing an update on the path '_id.a' would modify the immutable field '_id'");
}
diff --git a/src/mongo/db/update/pullall_node_test.cpp b/src/mongo/db/update/pullall_node_test.cpp
index 4af970eb306..03ba5290d62 100644
--- a/src/mongo/db/update/pullall_node_test.cpp
+++ b/src/mongo/db/update/pullall_node_test.cpp
@@ -126,7 +126,7 @@ TEST_F(PullAllNodeTest, ApplyToNonArrayFails) {
setPathTaken("a.0");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"][0])),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"Cannot apply $pull to a non-array value");
}
diff --git a/src/mongo/db/update/push_node_test.cpp b/src/mongo/db/update/push_node_test.cpp
index ba9e988fb64..3525a4b8767 100644
--- a/src/mongo/db/update/push_node_test.cpp
+++ b/src/mongo/db/update/push_node_test.cpp
@@ -266,7 +266,7 @@ TEST_F(PushNodeTest, ApplyToNonArrayFails) {
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"The field 'a' must be an array but is of type int in document {_id: \"test_object\"}");
}
diff --git a/src/mongo/db/update/rename_node_test.cpp b/src/mongo/db/update/rename_node_test.cpp
index a72485b7e23..2267f51de6e 100644
--- a/src/mongo/db/update/rename_node_test.cpp
+++ b/src/mongo/db/update/rename_node_test.cpp
@@ -248,7 +248,7 @@ TEST_F(RenameNodeTest, MoveIntoArray) {
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"The destination field cannot be an array element, 'a.2' in doc "
"with _id: \"test_object\" has an array field called 'a'");
@@ -265,7 +265,7 @@ TEST_F(RenameNodeTest, MoveIntoArrayNoId) {
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"The destination field cannot be an array element, 'a.2' in doc "
"with no id has an array field called 'a'");
@@ -281,7 +281,7 @@ TEST_F(RenameNodeTest, MoveToArrayElement) {
setPathTaken("a.1");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"]["1"])),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"The destination field cannot be an array element, 'a.1' in doc "
"with _id: \"test_object\" has an array field called 'a'");
@@ -297,7 +297,7 @@ TEST_F(RenameNodeTest, MoveOutOfArray) {
setPathToCreate("b");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"The source field cannot be an array element, 'a.0' in doc with "
"_id: \"test_object\" has an array field called 'a'");
@@ -314,7 +314,7 @@ TEST_F(RenameNodeTest, MoveNonexistentEmbeddedFieldOut) {
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"cannot use the part (a of a.a) to traverse the element ({a: [ { a: 1 }, { b: 2 } ]})");
}
@@ -329,7 +329,7 @@ TEST_F(RenameNodeTest, MoveEmbeddedFieldOutWithElementNumber) {
setPathToCreate("b");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"The source field cannot be an array element, 'a.0.a' in doc with "
"_id: \"test_object\" has an array field called 'a'");
@@ -422,7 +422,7 @@ TEST_F(RenameNodeTest, ApplyCannotRemoveRequiredPartOfDBRef) {
mutablebson::Document doc(fromjson("{a: {$ref: 'c', $id: 0}}"));
setPathToCreate("b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::InvalidDBRef,
"The DBRef $ref field must be followed by a $id field");
}
@@ -460,7 +460,7 @@ TEST_F(RenameNodeTest, ApplyCannotRemoveImmutablePath) {
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Unsetting the path 'a.b' using $rename would modify the immutable field 'a.b'");
}
@@ -476,7 +476,7 @@ TEST_F(RenameNodeTest, ApplyCannotRemovePrefixOfImmutablePath) {
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Unsetting the path 'a' using $rename would modify the immutable field 'a.b'");
}
@@ -492,7 +492,7 @@ TEST_F(RenameNodeTest, ApplyCannotRemoveSuffixOfImmutablePath) {
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Unsetting the path 'a.b.c' using $rename would modify the immutable field 'a.b'");
}
@@ -525,7 +525,7 @@ TEST_F(RenameNodeTest, ApplyCannotCreateDollarPrefixedField) {
setPathToCreate("$bad");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::DollarPrefixedFieldName,
"The dollar ($) prefixed field '$bad' in '$bad' is not valid for storage.");
}
@@ -541,7 +541,7 @@ TEST_F(RenameNodeTest, ApplyCannotOverwriteImmutablePath) {
addImmutablePath("b");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["b"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Updating the path 'b' to b: 0 would modify the immutable field 'b'");
}
diff --git a/src/mongo/db/update/set_node_test.cpp b/src/mongo/db/update/set_node_test.cpp
index a7a6f793a10..792b7632c39 100644
--- a/src/mongo/db/update/set_node_test.cpp
+++ b/src/mongo/db/update/set_node_test.cpp
@@ -156,7 +156,7 @@ TEST_F(SetNodeTest, ApplyNonViablePathToCreate) {
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot create field 'b' in element {a: 5}");
}
@@ -385,7 +385,7 @@ TEST_F(SetNodeTest, ApplyPathNotViable) {
setPathToCreate("b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot create field 'b' in element {a: 1}");
}
@@ -400,7 +400,7 @@ TEST_F(SetNodeTest, ApplyPathNotViableArrray) {
setPathToCreate("b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot create field 'b' in element {a: [ { b: 1 } ]}");
}
@@ -560,7 +560,7 @@ TEST_F(SetNodeTest, ApplyNonViablePath) {
setPathToCreate("2.b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot create field '2' in element {a: 0}");
}
@@ -789,7 +789,7 @@ TEST_F(SetNodeTest, NonViablePathWithoutRepl) {
setPathToCreate("1.b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot create field '1' in element {a: 1}");
}
@@ -973,7 +973,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateDollarPrefixedFieldInsideSetElement) {
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::DollarPrefixedFieldName,
"The dollar ($) prefixed field '$bad' in 'a.$bad' is not valid for storage.");
}
@@ -988,7 +988,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateDollarPrefixedFieldAtStartOfPath) {
setPathToCreate("$bad.a");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::DollarPrefixedFieldName,
"The dollar ($) prefixed field '$bad' in '$bad' is not valid for storage.");
}
@@ -1003,7 +1003,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateDollarPrefixedFieldInMiddleOfPath) {
setPathToCreate("a.$bad.b");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::DollarPrefixedFieldName,
"The dollar ($) prefixed field '$bad' in 'a.$bad' is not valid for storage.");
}
@@ -1018,7 +1018,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateDollarPrefixedFieldAtEndOfPath) {
setPathToCreate("a.$bad");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::DollarPrefixedFieldName,
"The dollar ($) prefixed field '$bad' in 'a.$bad' is not valid for storage.");
}
@@ -1053,7 +1053,7 @@ TEST_F(SetNodeTest, ApplyCannotOverwriteImmutablePath) {
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"]["b"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Updating the path 'a.b' to b: 1 would modify the immutable field 'a.b'");
}
@@ -1088,7 +1088,7 @@ TEST_F(SetNodeTest, ApplyCannotOverwritePrefixToRemoveImmutablePath) {
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"After applying the update, the immutable field 'a.b' was found to have been removed.");
}
@@ -1103,7 +1103,7 @@ TEST_F(SetNodeTest, ApplyCannotOverwritePrefixToModifyImmutablePath) {
setPathTaken("a");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"After applying the update, the immutable field 'a.b' was found to "
"have been altered to b: 1");
@@ -1177,7 +1177,7 @@ TEST_F(SetNodeTest, ApplyCannotOverwriteSuffixOfImmutablePath) {
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"]["b"]["c"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Updating the path 'a.b.c' to c: 1 would modify the immutable field 'a.b'");
}
@@ -1213,7 +1213,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateFieldAtEndOfImmutablePath) {
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"]["b"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Updating the path 'a.b' to b: { c: 1 } would modify the immutable field 'a.b'");
}
@@ -1230,7 +1230,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateFieldBeyondEndOfImmutablePath) {
addImmutablePath("a");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"]["b"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Updating the path 'a.b' to b: { c: 1 } would modify the immutable field 'a'");
}
diff --git a/src/mongo/db/update/unset_node_test.cpp b/src/mongo/db/update/unset_node_test.cpp
index 94be0fadb2d..f1c43b4c6fa 100644
--- a/src/mongo/db/update/unset_node_test.cpp
+++ b/src/mongo/db/update/unset_node_test.cpp
@@ -335,7 +335,7 @@ TEST_F(UnsetNodeTest, ApplyCannotRemoveRequiredPartOfDBRef) {
mutablebson::Document doc(fromjson("{a: {$ref: 'c', $id: 0}}"));
setPathTaken("a.$id");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"]["$id"])),
- UserException,
+ AssertionException,
ErrorCodes::InvalidDBRef,
"The DBRef $ref field must be followed by a $id field");
}
@@ -370,7 +370,7 @@ TEST_F(UnsetNodeTest, ApplyCannotRemoveImmutablePath) {
setPathTaken("a.b");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"]["b"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Unsetting the path 'a.b' would modify the immutable field 'a.b'");
}
@@ -385,7 +385,7 @@ TEST_F(UnsetNodeTest, ApplyCannotRemovePrefixOfImmutablePath) {
setPathTaken("a");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Unsetting the path 'a' would modify the immutable field 'a.b'");
}
@@ -401,7 +401,7 @@ TEST_F(UnsetNodeTest, ApplyCannotRemoveSuffixOfImmutablePath) {
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"]["b"]["c"])),
- UserException,
+ AssertionException,
ErrorCodes::ImmutableField,
"Unsetting the path 'a.b.c' would modify the immutable field 'a.b'");
}
diff --git a/src/mongo/db/update/update_array_node_test.cpp b/src/mongo/db/update/update_array_node_test.cpp
index 42087846813..fc76b08e418 100644
--- a/src/mongo/db/update/update_array_node_test.cpp
+++ b/src/mongo/db/update/update_array_node_test.cpp
@@ -63,7 +63,7 @@ TEST_F(UpdateArrayNodeTest, ApplyCreatePathFails) {
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(
root.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"The path 'a.b' must exist in the document in order to apply array updates.");
}
@@ -86,7 +86,7 @@ TEST_F(UpdateArrayNodeTest, ApplyToNonArrayFails) {
mutablebson::Document doc(fromjson("{a: {}}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"Cannot apply array updates to non-array element a: {}");
}
@@ -370,7 +370,7 @@ TEST_F(UpdateArrayNodeTest, ApplyUpdatesWithMergeConflictToArrayElementFails) {
mutablebson::Document doc(fromjson("{a: [0]}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'a.0'");
}
@@ -401,7 +401,7 @@ TEST_F(UpdateArrayNodeTest, ApplyUpdatesWithEmptyIdentifiersWithMergeConflictToA
mutablebson::Document doc(fromjson("{a: [{b: [0]}]}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'a.0.b.0'");
}
@@ -436,7 +436,7 @@ TEST_F(UpdateArrayNodeTest, ApplyNestedArrayUpdatesWithMergeConflictFails) {
mutablebson::Document doc(fromjson("{a: [{b: [0], c: 0}]}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'a.0.b.0'");
}
@@ -659,7 +659,7 @@ TEST_F(UpdateArrayNodeTest, ApplyArrayUpdateNotFromReplication) {
mutablebson::Document doc(fromjson("{a: [0]}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot create field 'b' in element {0: 0}");
}
diff --git a/src/mongo/db/update/update_driver_test.cpp b/src/mongo/db/update/update_driver_test.cpp
index 26dfb44cf79..52a4baa8b9a 100644
--- a/src/mongo/db/update/update_driver_test.cpp
+++ b/src/mongo/db/update/update_driver_test.cpp
@@ -90,7 +90,7 @@ TEST(Parse, EmptyMod) {
std::map<StringData, std::unique_ptr<ExpressionWithPlaceholder>> arrayFilters;
ASSERT_THROWS_CODE_AND_WHAT(
driver.parse(fromjson("{$set:{}}"), arrayFilters).transitional_ignore(),
- UserException,
+ AssertionException,
ErrorCodes::FailedToParse,
"'$set' is empty. You must specify a field like so: {$set: {<field>: ...}}");
}
@@ -101,7 +101,7 @@ TEST(Parse, WrongMod) {
std::map<StringData, std::unique_ptr<ExpressionWithPlaceholder>> arrayFilters;
ASSERT_THROWS_CODE_AND_WHAT(
driver.parse(fromjson("{$xyz:{a:1}}"), arrayFilters).transitional_ignore(),
- UserException,
+ AssertionException,
ErrorCodes::FailedToParse,
"Unknown modifier: $xyz");
}
@@ -112,7 +112,7 @@ TEST(Parse, WrongType) {
std::map<StringData, std::unique_ptr<ExpressionWithPlaceholder>> arrayFilters;
ASSERT_THROWS_CODE_AND_WHAT(
driver.parse(fromjson("{$set:[{a:1}]}"), arrayFilters).transitional_ignore(),
- UserException,
+ AssertionException,
ErrorCodes::FailedToParse,
"Modifiers operate on fields but we found type array instead. For "
"example: {$mod: {<field>: ...}} not {$set: [ { a: 1 } ]}");
@@ -125,7 +125,7 @@ TEST(Parse, ModsWithLaterObjReplacement) {
ASSERT_THROWS_CODE_AND_WHAT(
driver.parse(fromjson("{$set:{a:1}, obj: \"obj replacement\"}"), arrayFilters)
.transitional_ignore(),
- UserException,
+ AssertionException,
ErrorCodes::FailedToParse,
"Unknown modifier: obj");
}
diff --git a/src/mongo/db/update/update_leaf_node.h b/src/mongo/db/update/update_leaf_node.h
index 3e0b5b4d095..c268facec30 100644
--- a/src/mongo/db/update/update_leaf_node.h
+++ b/src/mongo/db/update/update_leaf_node.h
@@ -57,7 +57,7 @@ public:
* it. If 'element' is not an embedded object or array (e.g., we are trying to create path
* "a.b.c" in the document {a: 1}) or 'element' is an array but the first component in
* 'pathToCreate' is not an array index (e.g., the path "a.b.c" in the document
- * {a: [{b: 1}, {b: 2}]}), then this function throws a UserException with
+ * {a: [{b: 1}, {b: 2}]}), then this function throws a AssertionException with
* ErrorCode::PathNotViable. Otherwise, this function is a no-op.
*
* With the exception of $unset, update modifiers that do not create nonexistent paths ($pop,
diff --git a/src/mongo/db/update/update_node.h b/src/mongo/db/update/update_node.h
index 180f5755ecb..b8cb17dbb9a 100644
--- a/src/mongo/db/update/update_node.h
+++ b/src/mongo/db/update/update_node.h
@@ -150,8 +150,8 @@ public:
* Creates a new node by merging the contents of two input nodes. The semantics of the merge
* operation depend on the types of the input nodes. When the nodes have the same type, this
* function dispatches the merge to a createUpdateNodeByMerging implementation defined for that
- * subtype. Throws UserException with a ConflictingUpdateOperators code when the types of the
- * input nodes differ or when any of the child nodes fail to merge.
+ * subtype. Throws AssertionException with a ConflictingUpdateOperators code when the types of
+ * the input nodes differ or when any of the child nodes fail to merge.
*/
static std::unique_ptr<UpdateNode> createUpdateNodeByMerging(const UpdateNode& leftNode,
const UpdateNode& rightNode,
diff --git a/src/mongo/db/update/update_object_node_test.cpp b/src/mongo/db/update/update_object_node_test.cpp
index 6bb3d2c51c8..37569cdea05 100644
--- a/src/mongo/db/update/update_object_node_test.cpp
+++ b/src/mongo/db/update/update_object_node_test.cpp
@@ -1328,7 +1328,7 @@ TEST(UpdateObjectNodeTest, TopLevelConflictFails) {
std::unique_ptr<UpdateNode> result;
ASSERT_THROWS_CODE_AND_WHAT(
result = UpdateNode::createUpdateNodeByMerging(setRoot1, setRoot2, &fakeFieldRef),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'root.a'");
}
@@ -1357,7 +1357,7 @@ TEST(UpdateObjectNodeTest, NestedConflictFails) {
std::unique_ptr<UpdateNode> result;
ASSERT_THROWS_CODE_AND_WHAT(
result = UpdateNode::createUpdateNodeByMerging(setRoot1, setRoot2, &fakeFieldRef),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'root.a.b'");
}
@@ -1386,7 +1386,7 @@ TEST(UpdateObjectNodeTest, LeftPrefixMergeFails) {
std::unique_ptr<UpdateNode> result;
ASSERT_THROWS_CODE_AND_WHAT(
result = UpdateNode::createUpdateNodeByMerging(setRoot1, setRoot2, &fakeFieldRef),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'root.a.b'");
}
@@ -1415,7 +1415,7 @@ TEST(UpdateObjectNodeTest, RightPrefixMergeFails) {
std::unique_ptr<UpdateNode> result;
ASSERT_THROWS_CODE_AND_WHAT(
result = UpdateNode::createUpdateNodeByMerging(setRoot1, setRoot2, &fakeFieldRef),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'root.a.b'");
}
@@ -1444,7 +1444,7 @@ TEST(UpdateObjectNodeTest, LeftPrefixMergeThroughPositionalFails) {
std::unique_ptr<UpdateNode> result;
ASSERT_THROWS_CODE_AND_WHAT(
result = UpdateNode::createUpdateNodeByMerging(setRoot1, setRoot2, &fakeFieldRef),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'root.a.$.c'");
}
@@ -1473,7 +1473,7 @@ TEST(UpdateObjectNodeTest, RightPrefixMergeThroughPositionalFails) {
std::unique_ptr<UpdateNode> result;
ASSERT_THROWS_CODE_AND_WHAT(
result = UpdateNode::createUpdateNodeByMerging(setRoot1, setRoot2, &fakeFieldRef),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'root.a.$.c'");
}
@@ -1502,7 +1502,7 @@ TEST(UpdateObjectNodeTest, MergeWithConflictingPositionalFails) {
std::unique_ptr<UpdateNode> result;
ASSERT_THROWS_CODE_AND_WHAT(
result = UpdateNode::createUpdateNodeByMerging(setRoot1, setRoot2, &fakeFieldRef),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'root.a.$'");
}
@@ -1564,7 +1564,7 @@ TEST(UpdateObjectNodeTest, MergingArrayNodeWithObjectNodeFails) {
std::unique_ptr<UpdateNode> result;
ASSERT_THROWS_CODE_AND_WHAT(
result = UpdateNode::createUpdateNodeByMerging(setRoot1, setRoot2, &fakeFieldRef),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'root.a'");
}
@@ -1595,7 +1595,7 @@ TEST(UpdateObjectNodeTest, MergingArrayNodeWithLeafNodeFails) {
std::unique_ptr<UpdateNode> result;
ASSERT_THROWS_CODE_AND_WHAT(
result = UpdateNode::createUpdateNodeByMerging(setRoot1, setRoot2, &fakeFieldRef),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'root.a'");
}
@@ -1666,7 +1666,7 @@ TEST(UpdateObjectNodeTest, MergeConflictThroughArrayNodesFails) {
std::unique_ptr<UpdateNode> result;
ASSERT_THROWS_CODE_AND_WHAT(
result = UpdateNode::createUpdateNodeByMerging(setRoot1, setRoot2, &fakeFieldRef),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'root.a.$[i].b'");
}
@@ -2088,7 +2088,7 @@ TEST_F(UpdateObjectNodeTest, ApplyBlockingElement) {
mutablebson::Document doc(fromjson("{a: 0}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot create field 'b' in element {a: 0}");
}
@@ -2140,7 +2140,7 @@ TEST_F(UpdateObjectNodeTest, ApplyPositionalMissingMatchedField) {
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(
root.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::BadValue,
"The positional operator did not find the match needed from the query.");
}
@@ -2241,7 +2241,7 @@ TEST_F(UpdateObjectNodeTest, ApplyMergeConflictWithPositionalChild) {
setMatchedField("0");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::ConflictingUpdateOperators,
"Update created a conflict at 'a.0'");
}
@@ -2489,7 +2489,7 @@ TEST_F(UpdateObjectNodeTest, ApplyUpdateToNonViablePathInArray) {
mutablebson::Document doc(fromjson("{a: [{b: 1}, {b: 2}]}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
- UserException,
+ AssertionException,
ErrorCodes::PathNotViable,
"Cannot create field 'b' in element {a: [ { b: 1 }, { b: 2 } ]}");
}
diff --git a/src/mongo/db/views/resolved_view_test.cpp b/src/mongo/db/views/resolved_view_test.cpp
index 05c47d3fd51..af6152e13c8 100644
--- a/src/mongo/db/views/resolved_view_test.cpp
+++ b/src/mongo/db/views/resolved_view_test.cpp
@@ -178,33 +178,33 @@ TEST(ResolvedViewTest, ExpandingAggRequestPreservesComment) {
TEST(ResolvedViewTest, FromBSONFailsIfMissingResolvedView) {
BSONObj badCmdResponse = BSON("x" << 1);
- ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), UserException, 40248);
+ ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), AssertionException, 40248);
}
TEST(ResolvedViewTest, FromBSONFailsOnResolvedViewBadType) {
BSONObj badCmdResponse = BSON("resolvedView" << 7);
- ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), UserException, 40249);
+ ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), AssertionException, 40249);
}
TEST(ResolvedViewTest, FromBSONFailsIfMissingViewNs) {
BSONObj badCmdResponse = BSON("resolvedView" << BSON("pipeline" << BSONArray()));
- ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), UserException, 40250);
+ ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), AssertionException, 40250);
}
TEST(ResolvedViewTest, FromBSONFailsOnInvalidViewNsType) {
BSONObj badCmdResponse = BSON("resolvedView" << BSON("ns" << 8));
- ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), UserException, 40250);
+ ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), AssertionException, 40250);
}
TEST(ResolvedViewTest, FromBSONFailsIfMissingPipeline) {
BSONObj badCmdResponse = BSON("resolvedView" << BSON("ns" << backingNss.ns()));
- ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), UserException, 40251);
+ ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), AssertionException, 40251);
}
TEST(ResolvedViewTest, FromBSONFailsOnInvalidPipelineType) {
BSONObj badCmdResponse =
BSON("resolvedView" << BSON("ns" << backingNss.ns() << "pipeline" << 7));
- ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), UserException, 40251);
+ ASSERT_THROWS_CODE(ResolvedView::fromBSON(badCmdResponse), AssertionException, 40251);
}
TEST(ResolvedViewTest, FromBSONSuccessfullyParsesEmptyBSONArrayIntoEmptyVector) {
diff --git a/src/mongo/db/views/view_catalog_test.cpp b/src/mongo/db/views/view_catalog_test.cpp
index ca25984533a..ce34d558fd6 100644
--- a/src/mongo/db/views/view_catalog_test.cpp
+++ b/src/mongo/db/views/view_catalog_test.cpp
@@ -143,7 +143,7 @@ TEST_F(ViewCatalogFixture, CreateViewWithPipelineFailsOnInvalidStageName) {
ASSERT_THROWS(
viewCatalog.createView(opCtx.get(), viewName, viewOn, invalidPipeline, emptyCollation)
.transitional_ignore(),
- UserException);
+ AssertionException);
}
TEST_F(ViewCatalogFixture, CreateViewOnInvalidCollectionName) {
diff --git a/src/mongo/dbtests/clienttests.cpp b/src/mongo/dbtests/clienttests.cpp
index c38910dfce2..31744d6767d 100644
--- a/src/mongo/dbtests/clienttests.cpp
+++ b/src/mongo/dbtests/clienttests.cpp
@@ -377,7 +377,8 @@ public:
DBDirectClient db(&opCtx);
db.createIndex(ns(), IndexSpec().addKey("aField"));
- ASSERT_THROWS(db.createIndex(ns(), IndexSpec().addKey("aField").unique()), UserException);
+ ASSERT_THROWS(db.createIndex(ns(), IndexSpec().addKey("aField").unique()),
+ AssertionException);
}
};
diff --git a/src/mongo/dbtests/directclienttests.cpp b/src/mongo/dbtests/directclienttests.cpp
index f62c14aef22..dcf60479927 100644
--- a/src/mongo/dbtests/directclienttests.cpp
+++ b/src/mongo/dbtests/directclienttests.cpp
@@ -137,8 +137,9 @@ public:
OperationContext& opCtx = *opCtxPtr;
DBDirectClient client(&opCtx);
- ASSERT_THROWS_CODE(
- client.query("", Query(), 1)->nextSafe(), UserException, ErrorCodes::InvalidNamespace);
+ ASSERT_THROWS_CODE(client.query("", Query(), 1)->nextSafe(),
+ AssertionException,
+ ErrorCodes::InvalidNamespace);
}
};
@@ -150,7 +151,7 @@ public:
DBDirectClient client(&opCtx);
ASSERT_THROWS_CODE(
- client.getMore("", 1, 1)->nextSafe(), UserException, ErrorCodes::InvalidNamespace);
+ client.getMore("", 1, 1)->nextSafe(), AssertionException, ErrorCodes::InvalidNamespace);
}
};
diff --git a/src/mongo/dbtests/gle_test.cpp b/src/mongo/dbtests/gle_test.cpp
index 1a3b1f9d2a5..635af201978 100644
--- a/src/mongo/dbtests/gle_test.cpp
+++ b/src/mongo/dbtests/gle_test.cpp
@@ -33,7 +33,7 @@
#include "mongo/dbtests/dbtests.h"
#include "mongo/util/assert_util.h"
-using mongo::MsgAssertionException;
+using mongo::AssertionException;
/**
* Test getLastError client handling
diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp
index 97377643f31..dd1c75faf09 100644
--- a/src/mongo/dbtests/indexupdatetests.cpp
+++ b/src/mongo/dbtests/indexupdatetests.cpp
@@ -774,8 +774,9 @@ public:
IndexSpec indexSpec;
indexSpec.addKey("a").addOptions(BSON("collation" << BSON("locale"
<< "fr")));
- ASSERT_THROWS_CODE(
- client.createIndex(_ns, indexSpec), UserException, ErrorCodes::CannotBuildIndexKeys);
+ ASSERT_THROWS_CODE(client.createIndex(_ns, indexSpec),
+ AssertionException,
+ ErrorCodes::CannotBuildIndexKeys);
}
};
diff --git a/src/mongo/dbtests/jsobjtests.cpp b/src/mongo/dbtests/jsobjtests.cpp
index 8d9cd48ff71..9f870c06168 100644
--- a/src/mongo/dbtests/jsobjtests.cpp
+++ b/src/mongo/dbtests/jsobjtests.cpp
@@ -1048,7 +1048,7 @@ public:
* should fail with an assertion
*/
nestedBSON = recursiveBSON(BSONObj::maxToStringRecursionDepth + 1);
- ASSERT_THROWS(nestedBSON.toString(s, false, true), UserException);
+ ASSERT_THROWS(nestedBSON.toString(s, false, true), AssertionException);
}
};
@@ -1554,8 +1554,8 @@ class LabelishOr : public LabelBase {
class Unallowed {
public:
void run() {
- ASSERT_THROWS(BSON(GT << 4), MsgAssertionException);
- ASSERT_THROWS(BSON("a" << 1 << GT << 4), MsgAssertionException);
+ ASSERT_THROWS(BSON(GT << 4), AssertionException);
+ ASSERT_THROWS(BSON("a" << 1 << GT << 4), AssertionException);
}
};
@@ -2040,7 +2040,7 @@ public:
void good(BSONObj o) {
if (o.storageValidEmbedded().isOK())
return;
- throw UserException(12528, (string) "should be ok for storage:" + o.toString());
+ throw AssertionException(12528, (string) "should be ok for storage:" + o.toString());
}
void bad(string s) {
@@ -2050,7 +2050,7 @@ public:
void bad(BSONObj o) {
if (!o.storageValidEmbedded().isOK())
return;
- throw UserException(12529, (string) "should NOT be ok for storage:" + o.toString());
+ throw AssertionException(12529, (string) "should NOT be ok for storage:" + o.toString());
}
void run() {
diff --git a/src/mongo/dbtests/jsontests.cpp b/src/mongo/dbtests/jsontests.cpp
index 5b889487604..b64f71ef630 100644
--- a/src/mongo/dbtests/jsontests.cpp
+++ b/src/mongo/dbtests/jsontests.cpp
@@ -646,7 +646,7 @@ class Bad {
public:
virtual ~Bad() {}
void run() {
- ASSERT_THROWS(fromjson(json()), MsgAssertionException);
+ ASSERT_THROWS(fromjson(json()), AssertionException);
}
protected:
diff --git a/src/mongo/dbtests/jstests.cpp b/src/mongo/dbtests/jstests.cpp
index 78ec85296f9..fa117f08b61 100644
--- a/src/mongo/dbtests/jstests.cpp
+++ b/src/mongo/dbtests/jstests.cpp
@@ -402,11 +402,11 @@ public:
BSONObj out;
- ASSERT_THROWS(s->invoke("blah.y = 'e'", 0, 0), mongo::UserException);
- ASSERT_THROWS(s->invoke("blah.a = 19;", 0, 0), mongo::UserException);
- ASSERT_THROWS(s->invoke("blah.zz.a = 19;", 0, 0), mongo::UserException);
- ASSERT_THROWS(s->invoke("blah.zz = { a : 19 };", 0, 0), mongo::UserException);
- ASSERT_THROWS(s->invoke("delete blah['x']", 0, 0), mongo::UserException);
+ ASSERT_THROWS(s->invoke("blah.y = 'e'", 0, 0), mongo::AssertionException);
+ ASSERT_THROWS(s->invoke("blah.a = 19;", 0, 0), mongo::AssertionException);
+ ASSERT_THROWS(s->invoke("blah.zz.a = 19;", 0, 0), mongo::AssertionException);
+ ASSERT_THROWS(s->invoke("blah.zz = { a : 19 };", 0, 0), mongo::AssertionException);
+ ASSERT_THROWS(s->invoke("delete blah['x']", 0, 0), mongo::AssertionException);
// read-only object itself can be overwritten
s->invoke("blah = {}", 0, 0);
diff --git a/src/mongo/dbtests/query_plan_executor.cpp b/src/mongo/dbtests/query_plan_executor.cpp
index b4d765b225d..839f69cff5d 100644
--- a/src/mongo/dbtests/query_plan_executor.cpp
+++ b/src/mongo/dbtests/query_plan_executor.cpp
@@ -288,7 +288,7 @@ public:
// has been killed due to the collection being dropped.
BSONObj objOut;
ASSERT_THROWS_CODE(
- outerExec->getNext(&objOut, nullptr), UserException, ErrorCodes::QueryPlanKilled);
+ outerExec->getNext(&objOut, nullptr), AssertionException, ErrorCodes::QueryPlanKilled);
}
};
diff --git a/src/mongo/dbtests/query_stage_tests.cpp b/src/mongo/dbtests/query_stage_tests.cpp
index 15056339954..474dad6fb4d 100644
--- a/src/mongo/dbtests/query_stage_tests.cpp
+++ b/src/mongo/dbtests/query_stage_tests.cpp
@@ -228,7 +228,7 @@ public:
params.bounds.boundInclusion = BoundInclusion::kIncludeBothStartAndEndKeys;
params.direction = 1;
- ASSERT_THROWS(countResults(params, BSON("baz" << 25)), MsgAssertionException);
+ ASSERT_THROWS(countResults(params, BSON("baz" << 25)), AssertionException);
}
};
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp
index 841086a01f2..e44b4374724 100644
--- a/src/mongo/dbtests/querytests.cpp
+++ b/src/mongo/dbtests/querytests.cpp
@@ -165,9 +165,9 @@ public:
.value());
// Check findOne() returning object, requiring indexed scan without index.
- ASSERT_THROWS(Helpers::findOne(&_opCtx, _collection, query, ret, true), UserException);
+ ASSERT_THROWS(Helpers::findOne(&_opCtx, _collection, query, ret, true), AssertionException);
// Check findOne() returning location, requiring indexed scan without index.
- ASSERT_THROWS(Helpers::findOne(&_opCtx, _collection, query, true), UserException);
+ ASSERT_THROWS(Helpers::findOne(&_opCtx, _collection, query, true), AssertionException);
addIndex(IndexSpec().addKey("b").unique(false));
@@ -327,7 +327,7 @@ public:
cursor->next();
}
}()),
- UserException,
+ AssertionException,
ErrorCodes::InterruptedAtShutdown);
// Revert the killop kill all flag.
@@ -370,7 +370,7 @@ public:
ASSERT_THROWS(
_client.getMore("unittests.querytests.GetMoreInvalidRequest_WRONG_NAMESPACE_FOR_CURSOR",
cursor->getCursorId()),
- UserException);
+ AssertionException);
// Check that the cursor still exists
{
@@ -540,7 +540,7 @@ public:
const char* ns = "unittests.querytests.TailCappedOnly";
_client.insert(ns, BSONObj());
ASSERT_THROWS(_client.query(ns, BSONObj(), 0, 0, 0, QueryOption_CursorTailable),
- UserException);
+ AssertionException);
}
};
@@ -1342,7 +1342,7 @@ public:
c->nextSafe();
}
}()),
- UserException);
+ AssertionException);
}
void insertNext() {
diff --git a/src/mongo/dbtests/validate_tests.cpp b/src/mongo/dbtests/validate_tests.cpp
index 189ff9e788d..c5e9d4b149a 100644
--- a/src/mongo/dbtests/validate_tests.cpp
+++ b/src/mongo/dbtests/validate_tests.cpp
@@ -706,7 +706,7 @@ public:
<< "partialFilterExpression"
<< BSON("a" << BSON("$eq" << 2))))
.transitional_ignore(),
- UserException);
+ AssertionException);
// Create a partial geo index that does not index the document.
auto status = dbtests::createIndexFromSpec(&_opCtx,
diff --git a/src/mongo/idl/idl_test.cpp b/src/mongo/idl/idl_test.cpp
index e8da5170fe5..9723f802d46 100644
--- a/src/mongo/idl/idl_test.cpp
+++ b/src/mongo/idl/idl_test.cpp
@@ -238,7 +238,7 @@ void TestParse(TestT test_value) {
ASSERT_EQUALS(element.type(), Test_bson_type);
if (Parser_bson_type != Test_bson_type) {
- ASSERT_THROWS(ParserT::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(ParserT::parse(ctxt, testDoc), AssertionException);
} else {
(void)ParserT::parse(ctxt, testDoc);
}
@@ -319,7 +319,7 @@ TEST(IDLOneTypeTests, TestNamespaceString) {
{
auto testBadDoc = BSON("value" << StringData("foo\0bar", 7));
- ASSERT_THROWS(One_namespacestring::parse(ctxt, testBadDoc), UserException);
+ ASSERT_THROWS(One_namespacestring::parse(ctxt, testBadDoc), AssertionException);
}
}
@@ -406,29 +406,29 @@ TEST(IDLStructTests, TestStrictStruct) {
// Negative: Missing 1 required field
{
auto testDoc = BSON("field2" << 123 << "field3" << 1234);
- ASSERT_THROWS(RequiredStrictField3::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(RequiredStrictField3::parse(ctxt, testDoc), AssertionException);
}
{
auto testDoc = BSON("field1" << 12 << "field3" << 1234);
- ASSERT_THROWS(RequiredStrictField3::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(RequiredStrictField3::parse(ctxt, testDoc), AssertionException);
}
{
auto testDoc = BSON("field1" << 12 << "field2" << 123);
- ASSERT_THROWS(RequiredStrictField3::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(RequiredStrictField3::parse(ctxt, testDoc), AssertionException);
}
// Negative: Extra field
{
auto testDoc =
BSON("field1" << 12 << "field2" << 123 << "field3" << 1234 << "field4" << 1234);
- ASSERT_THROWS(RequiredStrictField3::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(RequiredStrictField3::parse(ctxt, testDoc), AssertionException);
}
// Negative: Duplicate field
{
auto testDoc =
BSON("field1" << 12 << "field2" << 123 << "field3" << 1234 << "field2" << 12345);
- ASSERT_THROWS(RequiredStrictField3::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(RequiredStrictField3::parse(ctxt, testDoc), AssertionException);
}
}
// Positive: non-strict, ensure extra fields work
@@ -450,15 +450,15 @@ TEST(IDLStructTests, TestNonStrictStruct) {
// Negative: Missing 1 required field
{
auto testDoc = BSON("2" << 123 << "3" << 1234);
- ASSERT_THROWS(RequiredNonStrictField3::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(RequiredNonStrictField3::parse(ctxt, testDoc), AssertionException);
}
{
auto testDoc = BSON("1" << 12 << "3" << 1234);
- ASSERT_THROWS(RequiredNonStrictField3::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(RequiredNonStrictField3::parse(ctxt, testDoc), AssertionException);
}
{
auto testDoc = BSON("1" << 12 << "2" << 123);
- ASSERT_THROWS(RequiredNonStrictField3::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(RequiredNonStrictField3::parse(ctxt, testDoc), AssertionException);
}
// Positive: Extra field
@@ -470,14 +470,14 @@ TEST(IDLStructTests, TestNonStrictStruct) {
// Negative: Duplicate field
{
auto testDoc = BSON("1" << 12 << "2" << 123 << "3" << 1234 << "2" << 12345);
- ASSERT_THROWS(RequiredNonStrictField3::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(RequiredNonStrictField3::parse(ctxt, testDoc), AssertionException);
}
// Negative: Duplicate extra field
{
auto testDoc =
BSON("field4" << 1234 << "1" << 12 << "2" << 123 << "3" << 1234 << "field4" << 1234);
- ASSERT_THROWS(RequiredNonStrictField3::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(RequiredNonStrictField3::parse(ctxt, testDoc), AssertionException);
}
}
@@ -780,14 +780,14 @@ TEST(IDLArrayTests, TestBadArrays) {
{
auto testDoc = BSON("field1" << 123);
- ASSERT_THROWS(Simple_int_array::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(Simple_int_array::parse(ctxt, testDoc), AssertionException);
}
// Negative: Test array with mixed types
{
auto testDoc = BSON("field1" << BSON_ARRAY(1.2 << 3.4 << 5.6));
- ASSERT_THROWS(Simple_int_array::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(Simple_int_array::parse(ctxt, testDoc), AssertionException);
}
}
@@ -823,7 +823,7 @@ TEST(IDLArrayTests, TestBadArrayFieldNames) {
}
auto testDoc = builder.obj();
- ASSERT_THROWS(Simple_int_array::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(Simple_int_array::parse(ctxt, testDoc), AssertionException);
}
// Negative: bad start
@@ -836,7 +836,7 @@ TEST(IDLArrayTests, TestBadArrayFieldNames) {
}
auto testDoc = builder.obj();
- ASSERT_THROWS(Simple_int_array::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(Simple_int_array::parse(ctxt, testDoc), AssertionException);
}
// Negative: non-sequentially increasing
@@ -849,7 +849,7 @@ TEST(IDLArrayTests, TestBadArrayFieldNames) {
}
auto testDoc = builder.obj();
- ASSERT_THROWS(Simple_int_array::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(Simple_int_array::parse(ctxt, testDoc), AssertionException);
}
}
@@ -1017,7 +1017,7 @@ TEST(IDLBinData, TestMD5) {
uint8_t testData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
auto testDoc = BSON("value" << BSONBinData(testData, 15, MD5Type));
- ASSERT_THROWS(One_md5::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(One_md5::parse(ctxt, testDoc), AssertionException);
}
}
@@ -1035,7 +1035,7 @@ void TestBinDataParse() {
ASSERT_EQUALS(element.binDataType(), Test_bindata_type);
if (Parser_bindata_type != Test_bindata_type) {
- ASSERT_THROWS(ParserT::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(ParserT::parse(ctxt, testDoc), AssertionException);
} else {
(void)ParserT::parse(ctxt, testDoc);
}
@@ -1263,7 +1263,7 @@ TEST(IDLChainedType, TestDuplicateFields) {
<< "field2"
<< 123456);
- ASSERT_THROWS(Chained_struct_only::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(Chained_struct_only::parse(ctxt, testDoc), AssertionException);
}
@@ -1309,7 +1309,7 @@ TEST(IDLChainedType, TestChainedStructWithExtraFields) {
<< "pair")
<< "extraField"
<< 787);
- ASSERT_THROWS(Chained_struct_mixed::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(Chained_struct_mixed::parse(ctxt, testDoc), AssertionException);
}
@@ -1324,7 +1324,7 @@ TEST(IDLChainedType, TestChainedStructWithExtraFields) {
<< "pair")
<< "anyField"
<< 787);
- ASSERT_THROWS(Chained_struct_mixed::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(Chained_struct_mixed::parse(ctxt, testDoc), AssertionException);
}
// Duplicate object
@@ -1338,7 +1338,7 @@ TEST(IDLChainedType, TestChainedStructWithExtraFields) {
<< "objectField"
<< BSON("random"
<< "pair"));
- ASSERT_THROWS(Chained_struct_mixed::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(Chained_struct_mixed::parse(ctxt, testDoc), AssertionException);
}
// Duplicate field3
@@ -1352,7 +1352,7 @@ TEST(IDLChainedType, TestChainedStructWithExtraFields) {
<< "pair")
<< "field3"
<< "def");
- ASSERT_THROWS(Chained_struct_mixed::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(Chained_struct_mixed::parse(ctxt, testDoc), AssertionException);
}
}
@@ -1456,19 +1456,19 @@ TEST(IDLEnum, TestIntEnumNegative) {
{
auto testDoc = BSON("value"
<< "2");
- ASSERT_THROWS(One_int_enum::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(One_int_enum::parse(ctxt, testDoc), AssertionException);
}
// Test a value out of range
{
auto testDoc = BSON("value" << 4);
- ASSERT_THROWS(One_int_enum::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(One_int_enum::parse(ctxt, testDoc), AssertionException);
}
// Test a negative number
{
auto testDoc = BSON("value" << -1);
- ASSERT_THROWS(One_int_enum::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(One_int_enum::parse(ctxt, testDoc), AssertionException);
}
}
@@ -1478,14 +1478,14 @@ TEST(IDLEnum, TestStringEnumNegative) {
// Test int
{
auto testDoc = BSON("value" << 2);
- ASSERT_THROWS(One_string_enum::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(One_string_enum::parse(ctxt, testDoc), AssertionException);
}
// Test a value out of range
{
auto testDoc = BSON("value"
<< "foo");
- ASSERT_THROWS(One_string_enum::parse(ctxt, testDoc), UserException);
+ ASSERT_THROWS(One_string_enum::parse(ctxt, testDoc), AssertionException);
}
}
@@ -1578,28 +1578,32 @@ TEST(IDLCommand, TestConcatentateWithDbNegative) {
<< 1
<< "field2"
<< "five");
- ASSERT_THROWS(BasicConcatenateWithDbCommand::parse(ctxt, makeOMR(testDoc)), UserException);
+ ASSERT_THROWS(BasicConcatenateWithDbCommand::parse(ctxt, makeOMR(testDoc)),
+ AssertionException);
}
// Negative - namespace field wrong order
{
auto testDoc = BSON("field1" << 3 << "BasicConcatenateWithDbCommand" << 1 << "field2"
<< "five");
- ASSERT_THROWS(BasicConcatenateWithDbCommand::parse(ctxt, makeOMR(testDoc)), UserException);
+ ASSERT_THROWS(BasicConcatenateWithDbCommand::parse(ctxt, makeOMR(testDoc)),
+ AssertionException);
}
// Negative - namespace missing
{
auto testDoc = BSON("field1" << 3 << "field2"
<< "five");
- ASSERT_THROWS(BasicConcatenateWithDbCommand::parse(ctxt, makeOMR(testDoc)), UserException);
+ ASSERT_THROWS(BasicConcatenateWithDbCommand::parse(ctxt, makeOMR(testDoc)),
+ AssertionException);
}
// Negative - wrong type
{
auto testDoc = BSON("BasicConcatenateWithDbCommand" << 1 << "field1" << 3 << "field2"
<< "five");
- ASSERT_THROWS(BasicConcatenateWithDbCommand::parse(ctxt, makeOMR(testDoc)), UserException);
+ ASSERT_THROWS(BasicConcatenateWithDbCommand::parse(ctxt, makeOMR(testDoc)),
+ AssertionException);
}
// Negative - bad ns with embedded null
@@ -1607,7 +1611,8 @@ TEST(IDLCommand, TestConcatentateWithDbNegative) {
StringData sd1("db\0foo", 6);
auto testDoc = BSON("BasicConcatenateWithDbCommand" << sd1 << "field1" << 3 << "field2"
<< "five");
- ASSERT_THROWS(BasicConcatenateWithDbCommand::parse(ctxt, makeOMR(testDoc)), UserException);
+ ASSERT_THROWS(BasicConcatenateWithDbCommand::parse(ctxt, makeOMR(testDoc)),
+ AssertionException);
}
}
@@ -1655,21 +1660,21 @@ TEST(IDLCommand, TestIgnoredNegative) {
auto testDoc = BSON(
"BasicIgnoredCommand" << 1 << "field1" << 3 << "BasicIgnoredCommand" << 1 << "field2"
<< "five");
- ASSERT_THROWS(BasicIgnoredCommand::parse(ctxt, makeOMR(testDoc)), UserException);
+ ASSERT_THROWS(BasicIgnoredCommand::parse(ctxt, makeOMR(testDoc)), AssertionException);
}
// Negative - namespace field wrong order
{
auto testDoc = BSON("field1" << 3 << "BasicIgnoredCommand" << 1 << "field2"
<< "five");
- ASSERT_THROWS(BasicIgnoredCommand::parse(ctxt, makeOMR(testDoc)), UserException);
+ ASSERT_THROWS(BasicIgnoredCommand::parse(ctxt, makeOMR(testDoc)), AssertionException);
}
// Negative - namespace missing
{
auto testDoc = BSON("field1" << 3 << "field2"
<< "five");
- ASSERT_THROWS(BasicIgnoredCommand::parse(ctxt, makeOMR(testDoc)), UserException);
+ ASSERT_THROWS(BasicIgnoredCommand::parse(ctxt, makeOMR(testDoc)), AssertionException);
}
}
@@ -1770,7 +1775,7 @@ TEST(IDLDocSequence, TestMissingDB) {
OpMsgRequest request;
request.body = testTempDoc;
- ASSERT_THROWS(DocSequenceCommand::parse(ctxt, request), UserException);
+ ASSERT_THROWS(DocSequenceCommand::parse(ctxt, request), AssertionException);
}
// Positive: Test a command read and written to OpMsgRequest with content in DocumentSequence works
@@ -1835,7 +1840,7 @@ void TestBadDocSequences(StringData name, bool extraFieldAllowed) {
<< "world")}});
request.sequences.push_back({"structs", {BSON("foo" << 1)}});
- ASSERT_THROWS(TestT::parse(ctxt, request), UserException);
+ ASSERT_THROWS(TestT::parse(ctxt, request), AssertionException);
}
// Negative: Extra field in document sequence
@@ -1850,7 +1855,7 @@ void TestBadDocSequences(StringData name, bool extraFieldAllowed) {
request.sequences.push_back({"extra", {BSON("foo" << 1)}});
if (!extraFieldAllowed) {
- ASSERT_THROWS(TestT::parse(ctxt, request), UserException);
+ ASSERT_THROWS(TestT::parse(ctxt, request), AssertionException);
} else {
/*void*/ TestT::parse(ctxt, request);
}
@@ -1861,7 +1866,7 @@ void TestBadDocSequences(StringData name, bool extraFieldAllowed) {
OpMsgRequest request = OpMsgRequest::fromDBAndBody("db", testTempDoc);
request.sequences.push_back({"objects", {BSON("foo" << 1)}});
- ASSERT_THROWS(TestT::parse(ctxt, request), UserException);
+ ASSERT_THROWS(TestT::parse(ctxt, request), AssertionException);
}
// Negative: Missing field in both document sequence and body
@@ -1873,7 +1878,7 @@ void TestBadDocSequences(StringData name, bool extraFieldAllowed) {
BSON("value"
<< "world")}});
- ASSERT_THROWS(TestT::parse(ctxt, request), UserException);
+ ASSERT_THROWS(TestT::parse(ctxt, request), AssertionException);
}
}
@@ -1910,7 +1915,7 @@ void TestDuplicateDocSequences(StringData name) {
BSON("value"
<< "world")}});
- ASSERT_THROWS(DocSequenceCommand::parse(ctxt, request), UserException);
+ ASSERT_THROWS(DocSequenceCommand::parse(ctxt, request), AssertionException);
}
// Negative: Duplicate fields in doc sequence and body
@@ -1931,7 +1936,7 @@ void TestDuplicateDocSequences(StringData name) {
OpMsgRequest request = OpMsgRequest::fromDBAndBody("db", testTempDoc);
request.sequences.push_back({"objects", {BSON("foo" << 1)}});
- ASSERT_THROWS(DocSequenceCommand::parse(ctxt, request), UserException);
+ ASSERT_THROWS(DocSequenceCommand::parse(ctxt, request), AssertionException);
}
}
@@ -1964,7 +1969,7 @@ TEST(IDLDocSequence, TestEmptySequence) {
OpMsgRequest request = OpMsgRequest::fromDBAndBody("db", testTempDoc);
request.sequences.push_back({"structs", {}});
- ASSERT_THROWS(DocSequenceCommand::parse(ctxt, request), UserException);
+ ASSERT_THROWS(DocSequenceCommand::parse(ctxt, request), AssertionException);
}
// Positive: Empty document sequence
diff --git a/src/mongo/rpc/command_reply_test.cpp b/src/mongo/rpc/command_reply_test.cpp
index 7ef9a29b46b..77bf5ba59a1 100644
--- a/src/mongo/rpc/command_reply_test.cpp
+++ b/src/mongo/rpc/command_reply_test.cpp
@@ -94,7 +94,7 @@ TEST_F(ReplyTest, ParseAllFields) {
}
TEST_F(ReplyTest, EmptyMessageThrows) {
- ASSERT_THROWS(rpc::CommandReply{buildMessage()}, UserException);
+ ASSERT_THROWS(rpc::CommandReply{buildMessage()}, AssertionException);
}
TEST_F(ReplyTest, MetadataOnlyThrows) {
@@ -103,7 +103,7 @@ TEST_F(ReplyTest, MetadataOnlyThrows) {
auto metadata = metadataBob.done();
writeObj(metadata);
- ASSERT_THROWS(rpc::CommandReply{buildMessage()}, UserException);
+ ASSERT_THROWS(rpc::CommandReply{buildMessage()}, AssertionException);
}
TEST_F(ReplyTest, MetadataInvalidLengthThrows) {
@@ -120,7 +120,7 @@ TEST_F(ReplyTest, MetadataInvalidLengthThrows) {
auto commandReply = commandReplyBob.done();
writeObj(commandReply);
- ASSERT_THROWS(rpc::CommandReply{buildMessage()}, UserException);
+ ASSERT_THROWS(rpc::CommandReply{buildMessage()}, AssertionException);
}
TEST_F(ReplyTest, InvalidLengthThrows) {
@@ -138,6 +138,6 @@ TEST_F(ReplyTest, InvalidLengthThrows) {
DataView(const_cast<char*>(commandReply.objdata())).write<LittleEndian<int32_t>>(100000);
writeObj(commandReply, trueSize);
- ASSERT_THROWS(rpc::CommandReply{buildMessage()}, UserException);
+ ASSERT_THROWS(rpc::CommandReply{buildMessage()}, AssertionException);
}
}
diff --git a/src/mongo/rpc/command_request_test.cpp b/src/mongo/rpc/command_request_test.cpp
index 830c1f04472..aad6dd1d3ff 100644
--- a/src/mongo/rpc/command_request_test.cpp
+++ b/src/mongo/rpc/command_request_test.cpp
@@ -117,7 +117,7 @@ TEST(CommandRequest, EmptyCommandObjThrows) {
Message msg;
msg.setData(dbCommand, opCommandData.data(), opCommandData.size());
- ASSERT_THROWS_CODE(rpc::ParsedOpCommand::parse(msg), UserException, 39950);
+ ASSERT_THROWS_CODE(rpc::ParsedOpCommand::parse(msg), AssertionException, 39950);
}
TEST(CommandRequest, MismatchBetweenCommandNamesThrows) {
@@ -152,7 +152,7 @@ TEST(CommandRequest, MismatchBetweenCommandNamesThrows) {
Message msg;
msg.setData(dbCommand, opCommandData.data(), opCommandData.size());
- ASSERT_THROWS_CODE(rpc::ParsedOpCommand::parse(msg), UserException, 39950);
+ ASSERT_THROWS_CODE(rpc::ParsedOpCommand::parse(msg), AssertionException, 39950);
}
} // namespace
diff --git a/src/mongo/rpc/metadata_test.cpp b/src/mongo/rpc/metadata_test.cpp
index aa18238c3a0..7524045b1b4 100644
--- a/src/mongo/rpc/metadata_test.cpp
+++ b/src/mongo/rpc/metadata_test.cpp
@@ -122,7 +122,7 @@ TEST(Metadata, UpconvertInvalidMetadata) {
<< "$maxTimeMS"
<< 200),
0),
- UserException,
+ AssertionException,
ErrorCodes::InvalidOptions);
ASSERT_THROWS_CODE(upconvertRequest("db",
BSON("$query" << BSON("foo"
@@ -130,22 +130,22 @@ TEST(Metadata, UpconvertInvalidMetadata) {
<< "$maxTimeMS"
<< 200),
0),
- UserException,
+ AssertionException,
ErrorCodes::InvalidOptions);
// invalid wrapped query
- ASSERT_THROWS(upconvertRequest("db", BSON("$query" << 1), 0), UserException);
+ ASSERT_THROWS(upconvertRequest("db", BSON("$query" << 1), 0), AssertionException);
ASSERT_THROWS(upconvertRequest("db",
BSON("$query"
<< ""),
0),
- UserException);
- ASSERT_THROWS(upconvertRequest("db", BSON("query" << 0), 0), UserException);
+ AssertionException);
+ ASSERT_THROWS(upconvertRequest("db", BSON("query" << 0), 0), AssertionException);
ASSERT_THROWS(upconvertRequest("db",
BSON("query"
<< ""),
0),
- UserException);
+ AssertionException);
}
diff --git a/src/mongo/s/async_requests_sender.cpp b/src/mongo/s/async_requests_sender.cpp
index 55f63010a13..71080bad767 100644
--- a/src/mongo/s/async_requests_sender.cpp
+++ b/src/mongo/s/async_requests_sender.cpp
@@ -94,7 +94,7 @@ AsyncRequestsSender::Response AsyncRequestsSender::next() {
if (_interruptStatus.isOK()) {
try {
_notification->get(_opCtx);
- } catch (const UserException& ex) {
+ } catch (const AssertionException& ex) {
// If the operation is interrupted, we cancel outstanding requests and switch to
// waiting for the (canceled) callbacks to finish without checking for interrupts.
_interruptStatus = ex.toStatus();
diff --git a/src/mongo/s/catalog/sharding_catalog_shard_collection_test.cpp b/src/mongo/s/catalog/sharding_catalog_shard_collection_test.cpp
index ae0ea1b4b56..b6229735979 100644
--- a/src/mongo/s/catalog/sharding_catalog_shard_collection_test.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_shard_collection_test.cpp
@@ -141,7 +141,7 @@ TEST_F(ShardCollectionTest, anotherMongosSharding) {
false,
vector<BSONObj>{},
false),
- UserException,
+ AssertionException,
ErrorCodes::ManualInterventionRequired);
}
diff --git a/src/mongo/s/client/parallel.cpp b/src/mongo/s/client/parallel.cpp
index a7ddaefbe54..23594f586da 100644
--- a/src/mongo/s/client/parallel.cpp
+++ b/src/mongo/s/client/parallel.cpp
@@ -68,7 +68,7 @@ void throwCursorError(DBClientCursor* cursor) {
if (cursor->hasResultFlag(ResultFlag_ErrSet)) {
BSONObj o = cursor->next();
- throw UserException(o["code"].numberInt(), o["$err"].str());
+ throw AssertionException(o["code"].numberInt(), o["$err"].str());
}
}
diff --git a/src/mongo/s/client/sharding_connection_hook.cpp b/src/mongo/s/client/sharding_connection_hook.cpp
index 743a158ca13..f2325d4c88a 100644
--- a/src/mongo/s/client/sharding_connection_hook.cpp
+++ b/src/mongo/s/client/sharding_connection_hook.cpp
@@ -54,8 +54,8 @@ ShardingConnectionHook::ShardingConnectionHook(bool shardedConnections,
void ShardingConnectionHook::onCreate(DBClientBase* conn) {
if (conn->type() == ConnectionString::INVALID) {
- throw UserException(ErrorCodes::BadValue,
- str::stream() << "Unrecognized connection string.");
+ throw AssertionException(ErrorCodes::BadValue,
+ str::stream() << "Unrecognized connection string.");
}
// Authenticate as the first thing we do
diff --git a/src/mongo/s/stale_exception.h b/src/mongo/s/stale_exception.h
index 1661320db8e..36f30c7fecb 100644
--- a/src/mongo/s/stale_exception.h
+++ b/src/mongo/s/stale_exception.h
@@ -81,14 +81,11 @@ public:
* stale config exceptions in a map and this requires a default constructor.
*/
StaleConfigException()
- : AssertionException(0, "initializing empty stale config exception object") {}
+ : AssertionException(ErrorCodes::InternalError,
+ "initializing empty stale config exception object") {}
virtual ~StaleConfigException() throw() {}
- virtual void appendPrefix(std::stringstream& ss) const {
- ss << "stale sharding config exception: ";
- }
-
std::string getns() const {
return _ns;
}
diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp
index e0ef5b9ba3a..a743f667111 100644
--- a/src/mongo/shell/bench.cpp
+++ b/src/mongo/shell/bench.cpp
@@ -631,7 +631,7 @@ void doNothing(const BSONObj&) {}
* single object in the query result set (or the empty object, if the result set is empty).
* If 'qr' doesn't have these options set, then nullptr must be passed for 'objOut'.
*
- * On error, throws a UserException.
+ * On error, throws a AssertionException.
*/
int runQueryWithReadCommands(DBClientBase* conn,
unique_ptr<QueryRequest> qr,
diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp
index 1edbbf1bba1..7b09e4f80ee 100644
--- a/src/mongo/shell/shell_options.cpp
+++ b/src/mongo/shell/shell_options.cpp
@@ -347,7 +347,7 @@ Status storeMongoShellOptions(const moe::Environment& params,
if (params.count("writeMode")) {
std::string mode = params["writeMode"].as<string>();
if (mode != "commands" && mode != "legacy" && mode != "compatibility") {
- throw MsgAssertionException(
+ throw AssertionException(
17396, mongoutils::str::stream() << "Unknown writeMode option: " << mode);
}
shellGlobalParams.writeMode = mode;
@@ -355,7 +355,7 @@ Status storeMongoShellOptions(const moe::Environment& params,
if (params.count("readMode")) {
std::string mode = params["readMode"].as<string>();
if (mode != "commands" && mode != "compatibility" && mode != "legacy") {
- throw MsgAssertionException(
+ throw AssertionException(
17397,
mongoutils::str::stream()
<< "Unknown readMode option: '"
@@ -368,10 +368,10 @@ Status storeMongoShellOptions(const moe::Environment& params,
std::string protos = params["rpcProtocols"].as<string>();
auto parsedRPCProtos = rpc::parseProtocolSet(protos);
if (!parsedRPCProtos.isOK()) {
- throw MsgAssertionException(28653,
- str::stream() << "Unknown RPC Protocols: '" << protos
- << "'. Valid values are {none, opQueryOnly, "
- << "opCommandOnly, all}");
+ throw AssertionException(28653,
+ str::stream() << "Unknown RPC Protocols: '" << protos
+ << "'. Valid values are {none, opQueryOnly, "
+ << "opCommandOnly, all}");
}
shellGlobalParams.rpcProtocols = parsedRPCProtos.getValue();
}
diff --git a/src/mongo/util/assert_util.cpp b/src/mongo/util/assert_util.cpp
index 05f2d9943d8..52e36c27c27 100644
--- a/src/mongo/util/assert_util.cpp
+++ b/src/mongo/util/assert_util.cpp
@@ -179,13 +179,6 @@ MONGO_COMPILER_NORETURN void fassertFailedWithStatusNoTraceWithLocation(int msgi
quickExit(EXIT_ABRUPT);
}
-void UserException::appendPrefix(stringstream& ss) const {
- ss << "userassert:";
-}
-void MsgAssertionException::appendPrefix(stringstream& ss) const {
- ss << "massert:";
-}
-
void uassertedWithLocation(int msgid, const string& msg, const char* file, unsigned line) {
uassertedWithLocation(msgid, msg.c_str(), file, line);
}
@@ -197,7 +190,7 @@ NOINLINE_DECL void uassertedWithLocation(int msgid,
assertionCount.condrollover(++assertionCount.user);
LOG(1) << "User Assertion: " << msgid << ":" << redact(msg) << ' ' << file << ' ' << dec << line
<< endl;
- throw UserException(msgid, msg);
+ throw AssertionException(msgid, msg);
}
void msgassertedWithLocation(int msgid, const string& msg, const char* file, unsigned line) {
@@ -212,7 +205,7 @@ NOINLINE_DECL void msgassertedWithLocation(int msgid,
error() << "Assertion: " << msgid << ":" << redact(msg) << ' ' << file << ' ' << dec << line
<< endl;
logContext();
- throw MsgAssertionException(msgid, msg);
+ throw AssertionException(msgid, msg);
}
NOINLINE_DECL void msgassertedNoTraceWithLocation(int msgid,
@@ -222,7 +215,7 @@ NOINLINE_DECL void msgassertedNoTraceWithLocation(int msgid,
assertionCount.condrollover(++assertionCount.warning);
error() << "Assertion: " << msgid << ":" << redact(msg) << ' ' << file << ' ' << dec << line
<< endl;
- throw MsgAssertionException(msgid, msg);
+ throw AssertionException(msgid, msg);
}
void msgassertedNoTraceWithLocation(int msgid,
diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h
index feebe646eec..3fd09b14faf 100644
--- a/src/mongo/util/assert_util.h
+++ b/src/mongo/util/assert_util.h
@@ -77,7 +77,6 @@ public:
return reason().c_str();
}
- virtual void appendPrefix(std::stringstream& ss) const {}
virtual void addContext(const std::string& str) {
_status = Status(code(), str + causedBy(reason()));
}
@@ -117,36 +116,6 @@ public:
AssertionException(int code, const std::string& msg) : DBException(code, msg) {}
virtual ~AssertionException() throw() {}
-
- virtual bool severe() const {
- return true;
- }
- virtual bool isUserAssertion() const {
- return false;
- }
-};
-
-/* UserExceptions are valid errors that a user can cause, like out of disk space or duplicate key */
-class UserException : public AssertionException {
-public:
- UserException(int c, const std::string& m) : AssertionException(c, m) {}
- virtual bool severe() const {
- return false;
- }
- virtual bool isUserAssertion() const {
- return true;
- }
- virtual void appendPrefix(std::stringstream& ss) const;
-};
-
-class MsgAssertionException : public AssertionException {
-public:
- MsgAssertionException(const Status& status) : AssertionException(status) {}
- MsgAssertionException(int c, const std::string& m) : AssertionException(c, m) {}
- virtual bool severe() const {
- return false;
- }
- virtual void appendPrefix(std::stringstream& ss) const;
};
MONGO_COMPILER_NORETURN void verifyFailed(const char* expr, const char* file, unsigned line);
@@ -406,7 +375,7 @@ inline void massertNoTraceStatusOKWithLocation(const Status& status,
// some special ids that we want to duplicate
// > 10000 asserts
-// < 10000 UserException
+// < 10000 AssertionException
enum { ASSERT_ID_DUPKEY = 11000 };
diff --git a/src/mongo/util/background_job_test.cpp b/src/mongo/util/background_job_test.cpp
index 5ca02ba41d7..4a1339e64f6 100644
--- a/src/mongo/util/background_job_test.cpp
+++ b/src/mongo/util/background_job_test.cpp
@@ -136,7 +136,7 @@ TEST(BackgroundJobLifeCycle, Go) {
j.go();
// Calling 'go' again while it is running is an error.
- ASSERT_THROWS(j.go(), MsgAssertionException);
+ ASSERT_THROWS(j.go(), AssertionException);
// Stop the Job
j.notify();
diff --git a/src/mongo/util/base64_test.cpp b/src/mongo/util/base64_test.cpp
index 8f856020d0f..e2c720fc13e 100644
--- a/src/mongo/util/base64_test.cpp
+++ b/src/mongo/util/base64_test.cpp
@@ -83,7 +83,7 @@ TEST(Base64Test, parseFail) {
try {
base64::decode(t.encoded);
ASSERT_TRUE(false);
- } catch (const UserException& e) {
+ } catch (const AssertionException& e) {
ASSERT_EQ(e.code(), t.code);
}
}
diff --git a/src/mongo/util/decorable_test.cpp b/src/mongo/util/decorable_test.cpp
index add3690b3ec..c7a234c3c77 100644
--- a/src/mongo/util/decorable_test.cpp
+++ b/src/mongo/util/decorable_test.cpp
@@ -145,7 +145,7 @@ TEST(DecorableTest, ThrowingConstructor) {
try {
DecorationContainer d(&registry);
- } catch (const UserException& ex) {
+ } catch (const AssertionException& ex) {
ASSERT_EQ(ErrorCodes::Unauthorized, ex.code());
}
ASSERT_EQ(1, numConstructedAs);
diff --git a/src/mongo/util/duration.h b/src/mongo/util/duration.h
index a040dd38d64..93ab483af89 100644
--- a/src/mongo/util/duration.h
+++ b/src/mongo/util/duration.h
@@ -97,9 +97,9 @@ using HigherPrecisionDuration =
/**
* Casts from one Duration precision to another.
*
- * May throw a UserException if "from" is of lower-precision type and is outside the range of the
- * ToDuration. For example, Seconds::max() cannot be represented as a Milliseconds, and
- * so attempting to cast that value to Milliseconds will throw an exception.
+ * May throw a AssertionException if "from" is of lower-precision type and is outside the range of
+ * the ToDuration. For example, Seconds::max() cannot be represented as a Milliseconds, and so
+ * attempting to cast that value to Milliseconds will throw an exception.
*/
template <typename ToDuration, typename FromPeriod>
ToDuration duration_cast(const Duration<FromPeriod>& from) {
@@ -232,7 +232,7 @@ public:
/**
* Constructs a higher-precision duration from a lower-precision one, as by duration_cast.
*
- * Throws a UserException if "from" is out of the range of this duration type.
+ * Throws a AssertionException if "from" is out of the range of this duration type.
*
* It is a compilation error to attempt a conversion from higher-precision to lower-precision by
* this constructor.
diff --git a/src/mongo/util/duration_test.cpp b/src/mongo/util/duration_test.cpp
index aac33feec99..af0f0dc8e00 100644
--- a/src/mongo/util/duration_test.cpp
+++ b/src/mongo/util/duration_test.cpp
@@ -136,10 +136,12 @@ TEST(DurationCast, TruncatingDurationCasts) {
}
TEST(DurationCast, OverflowingCastsThrow) {
- ASSERT_THROWS_CODE(
- duration_cast<Milliseconds>(Seconds::max()), UserException, ErrorCodes::DurationOverflow);
- ASSERT_THROWS_CODE(
- duration_cast<Milliseconds>(Seconds::min()), UserException, ErrorCodes::DurationOverflow);
+ ASSERT_THROWS_CODE(duration_cast<Milliseconds>(Seconds::max()),
+ AssertionException,
+ ErrorCodes::DurationOverflow);
+ ASSERT_THROWS_CODE(duration_cast<Milliseconds>(Seconds::min()),
+ AssertionException,
+ ErrorCodes::DurationOverflow);
}
TEST(DurationCast, ImplicitConversionToStdxDuration) {
@@ -165,17 +167,17 @@ TEST(DurationArithmetic, AddNoOverflowSucceeds) {
TEST(DurationArithmetic, AddOverflowThrows) {
// Max + 1 should throw
ASSERT_THROWS_CODE(
- Milliseconds::max() + Milliseconds{1}, UserException, ErrorCodes::DurationOverflow);
+ Milliseconds::max() + Milliseconds{1}, AssertionException, ErrorCodes::DurationOverflow);
// Min + -1 should throw
ASSERT_THROWS_CODE(
- Milliseconds::min() + Milliseconds{-1}, UserException, ErrorCodes::DurationOverflow);
+ Milliseconds::min() + Milliseconds{-1}, AssertionException, ErrorCodes::DurationOverflow);
// Conversion of Seconds::min() to Milliseconds should throw
ASSERT_THROWS_CODE(
- Seconds::min() + Milliseconds{1}, UserException, ErrorCodes::DurationOverflow);
+ Seconds::min() + Milliseconds{1}, AssertionException, ErrorCodes::DurationOverflow);
ASSERT_THROWS_CODE(
- Milliseconds{1} + Seconds::min(), UserException, ErrorCodes::DurationOverflow);
+ Milliseconds{1} + Seconds::min(), AssertionException, ErrorCodes::DurationOverflow);
}
TEST(DurationArithmetic, SubtractNoOverflowSucceeds) {
@@ -188,17 +190,17 @@ TEST(DurationArithmetic, SubtractNoOverflowSucceeds) {
TEST(DurationArithmetic, SubtractOverflowThrows) {
// Min - 1 should throw
ASSERT_THROWS_CODE(
- Milliseconds::min() - Milliseconds{1}, UserException, ErrorCodes::DurationOverflow);
+ Milliseconds::min() - Milliseconds{1}, AssertionException, ErrorCodes::DurationOverflow);
// Max + -1 should throw
ASSERT_THROWS_CODE(
- Milliseconds::max() - Milliseconds{-1}, UserException, ErrorCodes::DurationOverflow);
+ Milliseconds::max() - Milliseconds{-1}, AssertionException, ErrorCodes::DurationOverflow);
// Conversion of Seconds::min() to Milliseconds should throw
ASSERT_THROWS_CODE(
- Seconds::min() - Milliseconds{1}, UserException, ErrorCodes::DurationOverflow);
+ Seconds::min() - Milliseconds{1}, AssertionException, ErrorCodes::DurationOverflow);
ASSERT_THROWS_CODE(
- Milliseconds{1} - Seconds::min(), UserException, ErrorCodes::DurationOverflow);
+ Milliseconds{1} - Seconds::min(), AssertionException, ErrorCodes::DurationOverflow);
}
TEST(DurationArithmetic, MultiplyNoOverflowSucceds) {
@@ -207,10 +209,10 @@ TEST(DurationArithmetic, MultiplyNoOverflowSucceds) {
}
TEST(DurationArithmetic, MultilpyOverflowThrows) {
- ASSERT_THROWS_CODE(Milliseconds::max() * 2, UserException, ErrorCodes::DurationOverflow);
- ASSERT_THROWS_CODE(2 * Milliseconds::max(), UserException, ErrorCodes::DurationOverflow);
- ASSERT_THROWS_CODE(Milliseconds::max() * -2, UserException, ErrorCodes::DurationOverflow);
- ASSERT_THROWS_CODE(-2 * Milliseconds::max(), UserException, ErrorCodes::DurationOverflow);
+ ASSERT_THROWS_CODE(Milliseconds::max() * 2, AssertionException, ErrorCodes::DurationOverflow);
+ ASSERT_THROWS_CODE(2 * Milliseconds::max(), AssertionException, ErrorCodes::DurationOverflow);
+ ASSERT_THROWS_CODE(Milliseconds::max() * -2, AssertionException, ErrorCodes::DurationOverflow);
+ ASSERT_THROWS_CODE(-2 * Milliseconds::max(), AssertionException, ErrorCodes::DurationOverflow);
}
TEST(DurationArithmetic, DivideNoOverflowSucceeds) {
@@ -218,7 +220,7 @@ TEST(DurationArithmetic, DivideNoOverflowSucceeds) {
}
TEST(DurationArithmetic, DivideOverflowThrows) {
- ASSERT_THROWS_CODE(Milliseconds::min() / -1, UserException, ErrorCodes::DurationOverflow);
+ ASSERT_THROWS_CODE(Milliseconds::min() / -1, AssertionException, ErrorCodes::DurationOverflow);
}
} // namespace
diff --git a/src/mongo/util/net/op_msg_test.cpp b/src/mongo/util/net/op_msg_test.cpp
index b44aa8fa865..cadc36f6867 100644
--- a/src/mongo/util/net/op_msg_test.cpp
+++ b/src/mongo/util/net/op_msg_test.cpp
@@ -311,7 +311,7 @@ TEST_F(OpMsgParser, FailsIfNoBody) {
kNoFlags, //
};
- ASSERT_THROWS_CODE(msg.parse(), UserException, 40587);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, 40587);
}
TEST_F(OpMsgParser, FailsIfNoBodyEvenWithSequence) {
@@ -322,7 +322,7 @@ TEST_F(OpMsgParser, FailsIfNoBodyEvenWithSequence) {
Sized{"docs"},
};
- ASSERT_THROWS_CODE(msg.parse(), UserException, 40587);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, 40587);
}
TEST_F(OpMsgParser, FailsIfTwoBodies) {
@@ -335,7 +335,7 @@ TEST_F(OpMsgParser, FailsIfTwoBodies) {
fromjson("{pong: 1}"),
};
- ASSERT_THROWS_CODE(msg.parse(), UserException, 40430);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, 40430);
}
TEST_F(OpMsgParser, FailsIfDuplicateSequences) {
@@ -351,7 +351,7 @@ TEST_F(OpMsgParser, FailsIfDuplicateSequences) {
Sized{"docs"},
};
- ASSERT_THROWS_CODE(msg.parse(), UserException, 40431);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, 40431);
}
TEST_F(OpMsgParser, FailsIfDuplicateSequenceWithBody) {
@@ -364,7 +364,7 @@ TEST_F(OpMsgParser, FailsIfDuplicateSequenceWithBody) {
Sized{"docs"},
};
- ASSERT_THROWS_CODE(msg.parse(), UserException, 40433);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, 40433);
}
TEST_F(OpMsgParser, FailsIfDuplicateSequenceWithBodyNested) {
@@ -377,7 +377,7 @@ TEST_F(OpMsgParser, FailsIfDuplicateSequenceWithBodyNested) {
Sized{"a.b"},
};
- ASSERT_THROWS_CODE(msg.parse(), UserException, 40433);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, 40433);
}
TEST_F(OpMsgParser, SucceedsIfSequenceAndBodyHaveCommonPrefix) {
@@ -407,7 +407,7 @@ TEST_F(OpMsgParser, FailsIfUnknownSectionKind) {
Sized{},
};
- ASSERT_THROWS_CODE(msg.parse(), UserException, 40432);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, 40432);
}
TEST_F(OpMsgParser, FailsIfBodyTooBig) {
@@ -417,7 +417,7 @@ TEST_F(OpMsgParser, FailsIfBodyTooBig) {
fromjson("{ping: 1}"),
}.addToSize(-1); // Shrink message so body extends past end.
- ASSERT_THROWS_CODE(msg.parse(), UserException, ErrorCodes::InvalidBSON);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, ErrorCodes::InvalidBSON);
}
TEST_F(OpMsgParser, FailsIfBodyTooBigIntoChecksum) {
@@ -428,7 +428,7 @@ TEST_F(OpMsgParser, FailsIfBodyTooBigIntoChecksum) {
kFakeCRC,
}.addToSize(-1); // Shrink message so body extends past end.
- ASSERT_THROWS_CODE(msg.parse(), UserException, ErrorCodes::InvalidBSON);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, ErrorCodes::InvalidBSON);
}
TEST_F(OpMsgParser, FailsIfDocumentSequenceTooBig) {
@@ -444,7 +444,7 @@ TEST_F(OpMsgParser, FailsIfDocumentSequenceTooBig) {
},
}.addToSize(-1); // Shrink message so body extends past end.
- ASSERT_THROWS_CODE(msg.parse(), UserException, ErrorCodes::Overflow);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, ErrorCodes::Overflow);
}
TEST_F(OpMsgParser, FailsIfDocumentSequenceTooBigIntoChecksum) {
@@ -462,7 +462,7 @@ TEST_F(OpMsgParser, FailsIfDocumentSequenceTooBigIntoChecksum) {
kFakeCRC,
}.addToSize(-1); // Shrink message so body extends past end.
- ASSERT_THROWS_CODE(msg.parse(), UserException, ErrorCodes::Overflow);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, ErrorCodes::Overflow);
}
TEST_F(OpMsgParser, FailsIfDocumentInSequenceTooBig) {
@@ -478,7 +478,7 @@ TEST_F(OpMsgParser, FailsIfDocumentInSequenceTooBig) {
}.addToSize(-1), // Shrink sequence so document extends past end.
};
- ASSERT_THROWS_CODE(msg.parse(), UserException, ErrorCodes::InvalidBSON);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, ErrorCodes::InvalidBSON);
}
TEST_F(OpMsgParser, FailsIfNameOfDocumentSequenceTooBig) {
@@ -493,7 +493,7 @@ TEST_F(OpMsgParser, FailsIfNameOfDocumentSequenceTooBig) {
}.addToSize(-1), // Shrink sequence so document extends past end.
};
- ASSERT_THROWS_CODE(msg.parse(), UserException, ErrorCodes::Overflow);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, ErrorCodes::Overflow);
}
TEST_F(OpMsgParser, FailsIfNameOfDocumentSequenceHasNoNulTerminator) {
@@ -507,15 +507,16 @@ TEST_F(OpMsgParser, FailsIfNameOfDocumentSequenceHasNoNulTerminator) {
// No '\0' at end of document. ASAN should complain if we keep looking for one.
};
- ASSERT_THROWS_CODE(msg.parse(), UserException, ErrorCodes::Overflow);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, ErrorCodes::Overflow);
}
TEST_F(OpMsgParser, FailsIfNoRoomForFlags) {
// Flags are 4 bytes. Try 0-3 bytes.
- ASSERT_THROWS_CODE(OpMsgBytes{}.parse(), UserException, ErrorCodes::Overflow);
- ASSERT_THROWS_CODE(OpMsgBytes{'\0'}.parse(), UserException, ErrorCodes::Overflow);
- ASSERT_THROWS_CODE((OpMsgBytes{'\0', '\0'}.parse()), UserException, ErrorCodes::Overflow);
- ASSERT_THROWS_CODE((OpMsgBytes{'\0', '\0', '\0'}.parse()), UserException, ErrorCodes::Overflow);
+ ASSERT_THROWS_CODE(OpMsgBytes{}.parse(), AssertionException, ErrorCodes::Overflow);
+ ASSERT_THROWS_CODE(OpMsgBytes{'\0'}.parse(), AssertionException, ErrorCodes::Overflow);
+ ASSERT_THROWS_CODE((OpMsgBytes{'\0', '\0'}.parse()), AssertionException, ErrorCodes::Overflow);
+ ASSERT_THROWS_CODE(
+ (OpMsgBytes{'\0', '\0', '\0'}.parse()), AssertionException, ErrorCodes::Overflow);
}
TEST_F(OpMsgParser, FailsWithUnknownRequiredFlags) {
@@ -528,7 +529,7 @@ TEST_F(OpMsgParser, FailsWithUnknownRequiredFlags) {
fromjson("{ping: 1}"),
};
- ASSERT_THROWS_CODE(msg.parse(), UserException, 40429);
+ ASSERT_THROWS_CODE(msg.parse(), AssertionException, 40429);
}
}
@@ -744,10 +745,10 @@ TEST(OpMsgRequest, GetDatabaseThrowsWrongType) {
TEST(OpMsgRequest, GetDatabaseThrowsMissing) {
OpMsgRequest msg;
msg.body = fromjson("{}");
- ASSERT_THROWS(msg.getDatabase(), UserException);
+ ASSERT_THROWS(msg.getDatabase(), AssertionException);
msg.body = fromjson("{$notdb: 'foo'}");
- ASSERT_THROWS(msg.getDatabase(), UserException);
+ ASSERT_THROWS(msg.getDatabase(), AssertionException);
}
TEST(OpMsgRequest, FromDbAndBodyDoesNotCopy) {
diff --git a/src/mongo/util/options_parser/value.h b/src/mongo/util/options_parser/value.h
index f7d365b5f13..42818f60f2b 100644
--- a/src/mongo/util/options_parser/value.h
+++ b/src/mongo/util/options_parser/value.h
@@ -122,7 +122,7 @@ public:
*/
/**
- * Returns the contents of this Value as type T. Throws MsgAssertionException if the type
+ * Returns the contents of this Value as type T. Throws AssertionException if the type
* does not match
*/
template <typename T>
@@ -171,7 +171,7 @@ T Value::as() const {
if (!ret.isOK()) {
StringBuilder message;
message << "failed to extract typed value from Value container: " << ret.toString();
- throw MsgAssertionException(17114, message.str());
+ throw AssertionException(17114, message.str());
}
return valueType;
diff --git a/src/mongo/util/uuid.cpp b/src/mongo/util/uuid.cpp
index 5e5b133336a..32f69ca7d33 100644
--- a/src/mongo/util/uuid.cpp
+++ b/src/mongo/util/uuid.cpp
@@ -53,7 +53,7 @@ std::regex uuidRegex("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4
StatusWith<UUID> UUID::parse(BSONElement from) {
try {
return UUID{from.uuid()};
- } catch (const UserException& e) {
+ } catch (const AssertionException& e) {
return e.toStatus();
}
}