summaryrefslogtreecommitdiff
path: root/src/mongo/bson
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2013-10-07 15:23:43 -0400
committerScott Hernandez <scotthernandez@gmail.com>2013-10-08 10:05:53 -0400
commit4b5cfc190c702aad25a353d8b3e275f71599b05f (patch)
tree14edc9bd49074ccbefb96fb95c83b21003116da0 /src/mongo/bson
parent95566879c8fc1ea4ed61917d14367858167e15d2 (diff)
downloadmongo-4b5cfc190c702aad25a353d8b3e275f71599b05f.tar.gz
SERVER-10958: Update error messages and provide _id of error docs
Diffstat (limited to 'src/mongo/bson')
-rw-r--r--src/mongo/bson/mutable/element.cpp3
-rw-r--r--src/mongo/bson/mutable/element.h3
2 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/bson/mutable/element.cpp b/src/mongo/bson/mutable/element.cpp
index bb5504f63b5..e2e02d61fe4 100644
--- a/src/mongo/bson/mutable/element.cpp
+++ b/src/mongo/bson/mutable/element.cpp
@@ -150,6 +150,9 @@ namespace mutablebson {
}
std::string Element::toString() const {
+ if (!ok())
+ return "INVALID-MUTABLE-ELEMENT";
+
if (hasValue())
return getValue().toString();
diff --git a/src/mongo/bson/mutable/element.h b/src/mongo/bson/mutable/element.h
index fc3c67bdee4..e78933773d9 100644
--- a/src/mongo/bson/mutable/element.h
+++ b/src/mongo/bson/mutable/element.h
@@ -548,7 +548,8 @@ namespace mutablebson {
*/
Status appendSafeNum(const StringData& fieldName, SafeNum value);
- /** Convert this element to its JSON representation */
+ /** Convert this element to its JSON representation if ok(),
+ * otherwise return !ok() message */
std::string toString() const;
private: