summaryrefslogtreecommitdiff
path: root/src/mongo/bson/util/bson_extract.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/bson/util/bson_extract.cpp')
-rw-r--r--src/mongo/bson/util/bson_extract.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/mongo/bson/util/bson_extract.cpp b/src/mongo/bson/util/bson_extract.cpp
index 095185e4baa..b3ff37ca1b2 100644
--- a/src/mongo/bson/util/bson_extract.cpp
+++ b/src/mongo/bson/util/bson_extract.cpp
@@ -37,7 +37,8 @@ Status bsonExtractField(const BSONObj& object, StringData fieldName, BSONElement
if (element.eoo())
return Status(ErrorCodes::NoSuchKey,
mongoutils::str::stream() << "Missing expected field \""
- << fieldName.toString() << "\"");
+ << fieldName.toString()
+ << "\"");
*outElement = element;
return Status::OK();
}
@@ -51,9 +52,11 @@ Status bsonExtractTypedField(const BSONObj& object,
return status;
if (type != outElement->type()) {
return Status(ErrorCodes::TypeMismatch,
- mongoutils::str::stream()
- << "\"" << fieldName << "\" had the wrong type. Expected "
- << typeName(type) << ", found " << typeName(outElement->type()));
+ mongoutils::str::stream() << "\"" << fieldName
+ << "\" had the wrong type. Expected "
+ << typeName(type)
+ << ", found "
+ << typeName(outElement->type()));
}
return Status::OK();
}
@@ -81,7 +84,8 @@ Status bsonExtractBooleanFieldWithDefault(const BSONObj& object,
} else if (!value.isNumber() && !value.isBoolean()) {
return Status(ErrorCodes::TypeMismatch,
mongoutils::str::stream() << "Expected boolean or number type for field \""
- << fieldName << "\", found "
+ << fieldName
+ << "\", found "
<< typeName(value.type()));
} else {
*out = value.trueValue();
@@ -155,11 +159,12 @@ Status bsonExtractIntegerField(const BSONObj& object, StringData fieldName, long
}
long long result = value.safeNumberLong();
if (result != value.numberDouble()) {
- return Status(ErrorCodes::BadValue,
- mongoutils::str::stream()
- << "Expected field \"" << fieldName
- << "\" to have a value "
- "exactly representable as a 64-bit integer, but found " << value);
+ return Status(
+ ErrorCodes::BadValue,
+ mongoutils::str::stream() << "Expected field \"" << fieldName
+ << "\" to have a value "
+ "exactly representable as a 64-bit integer, but found "
+ << value);
}
*out = result;
return Status::OK();
@@ -188,9 +193,11 @@ Status bsonExtractIntegerFieldWithDefaultIf(const BSONObj& object,
return status;
}
if (!pred(*out)) {
- return Status(ErrorCodes::BadValue,
- mongoutils::str::stream() << "Invalid value in field \"" << fieldName
- << "\": " << *out << ": " << predDescription);
+ return Status(
+ ErrorCodes::BadValue,
+ mongoutils::str::stream() << "Invalid value in field \"" << fieldName << "\": " << *out
+ << ": "
+ << predDescription);
}
return Status::OK();
}