-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Internal Code
-
Server Programmability
In the statement:
uassert(errcode, message, expression);
We evaluate the truth of expression and its stringified form, but the values that went into it are lost. Currently I see the 'message' argument is often trying to encode a redundant representation of the 'expression' argument.
src/mongo/bson/util/bson_check.h-104- inline void checkBSONType(BSONType expectedType, const BSONElement& elem) { uassert(elem.type() == BSONType::EOO ? ErrorCodes::NoSuchKey : ErrorCodes::TypeMismatch, str::stream() << "Wrong type for '" << elem.fieldNameStringData() << "'. Expected a " << typeName(expectedType) << ", got a " << typeName(elem.type()) << '.', elem.type() == expectedType); }
Or just letting diagnostic info go to waste:
src/mongo/bson/ordering.h:81:
uassert(13103, "too many compound keys", n <= 31);
A simple library of matchers similar to google mock matchers could improve the situation considerably.
src/mongo/bson/util/bson_check.h-104- inline void checkBSONType(BSONType expectedType, const BSONElement& elem) { uassert(elem.type() == BSONType::EOO ? ErrorCodes::NoSuchKey : ErrorCodes::TypeMismatch, str::stream() << "Wrong type for '" << elem.fieldNameStringData(), Arg(elem.type()) == Arg(expectedType)); }
src/mongo/bson/ordering.h:81:
uassert(13103, "too many compound keys", Arg(n) <= Arg(31));
- is related to
-
SERVER-57956 richer invariant failure
- Backlog
- related to
-
SERVER-37517 Decompose expressions in ASSERT() to capture argument values
- Closed
-
SERVER-51888 Add TS2's std::is_detected etc API to stdx
- Closed