diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2021-01-27 15:43:41 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-28 00:12:32 +0000 |
commit | fd5d916299823608161ebf2473a17b58ddf14b5b (patch) | |
tree | b45bc710018683d08d857cb1d7a5f8255ebd409a /src/mongo/idl/idl_parser.cpp | |
parent | c65e6736ec25d5f2c6296014c6a16666a886f336 (diff) | |
download | mongo-fd5d916299823608161ebf2473a17b58ddf14b5b.tar.gz |
SERVER-51369 Generate C++ for IDL variants
Diffstat (limited to 'src/mongo/idl/idl_parser.cpp')
-rw-r--r-- | src/mongo/idl/idl_parser.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/mongo/idl/idl_parser.cpp b/src/mongo/idl/idl_parser.cpp index 89158281e92..9cad14bffca 100644 --- a/src/mongo/idl/idl_parser.cpp +++ b/src/mongo/idl/idl_parser.cpp @@ -110,12 +110,7 @@ bool IDLParserErrorContext::checkAndAssertTypes(const BSONElement& element, return false; } - std::string path = getElementPath(element); - std::string type_str = toCommaDelimitedList(types); - uasserted(ErrorCodes::TypeMismatch, - str::stream() << "BSON field '" << path << "' is the wrong type '" - << typeName(element.type()) << "', expected types '[" << type_str - << "']"); + throwBadType(element, types); } return true; @@ -225,6 +220,16 @@ void IDLParserErrorContext::throwBadEnumValue(StringData enumValue) const { << "' is not a valid value."); } +void IDLParserErrorContext::throwBadType(const BSONElement& element, + const std::vector<BSONType>& types) const { + std::string path = getElementPath(element); + std::string type_str = toCommaDelimitedList(types); + uasserted(ErrorCodes::TypeMismatch, + str::stream() << "BSON field '" << path << "' is the wrong type '" + << typeName(element.type()) << "', expected types '[" << type_str + << "']"); +} + void IDLParserErrorContext::throwAPIStrictErrorIfApplicable(BSONElement field) const { throwAPIStrictErrorIfApplicable(field.fieldNameStringData()); } |