diff options
author | Scott Hernandez <scotthernandez@gmail.com> | 2013-10-07 15:23:43 -0400 |
---|---|---|
committer | Scott Hernandez <scotthernandez@gmail.com> | 2013-10-08 10:05:53 -0400 |
commit | 4b5cfc190c702aad25a353d8b3e275f71599b05f (patch) | |
tree | 14edc9bd49074ccbefb96fb95c83b21003116da0 /src/mongo/db/ops/field_checker.cpp | |
parent | 95566879c8fc1ea4ed61917d14367858167e15d2 (diff) | |
download | mongo-4b5cfc190c702aad25a353d8b3e275f71599b05f.tar.gz |
SERVER-10958: Update error messages and provide _id of error docs
Diffstat (limited to 'src/mongo/db/ops/field_checker.cpp')
-rw-r--r-- | src/mongo/db/ops/field_checker.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/mongo/db/ops/field_checker.cpp b/src/mongo/db/ops/field_checker.cpp index 86d7981b24b..e4611727832 100644 --- a/src/mongo/db/ops/field_checker.cpp +++ b/src/mongo/db/ops/field_checker.cpp @@ -44,21 +44,25 @@ namespace fieldchecker { const size_t numParts = field.numParts(); if (numParts == 0) { - return Status(ErrorCodes::BadValue, "cannot update an empty field name"); + return Status(ErrorCodes::EmptyFieldName, + "An empty update path is not valid."); } for (size_t i = 0; i != numParts; ++i) { const StringData part = field.getPart(i); if ((i == 0) && part.compare("_id") == 0) { - return Status(ErrorCodes::BadValue, - "update cannot affect the _id"); + return Status(ErrorCodes::ImmutableIdField, + mongoutils::str::stream() << "The update path '" + << field.dottedField() + << "' contains the '_id' field, which cannot be updated."); } if (part.empty()) { - return Status(ErrorCodes::BadValue, - mongoutils::str::stream() << field.dottedField() - << " contains empty fields"); + return Status(ErrorCodes::EmptyFieldName, + mongoutils::str::stream() << "The update path '" + << field.dottedField() + << "' contains an empty field, which is not allowed."); } if (!legacy && (part[0] == '$')) { @@ -88,9 +92,11 @@ namespace fieldchecker { part.startsWith("$ref"); if (!mightBePartOfDbRef) - return Status(ErrorCodes::BadValue, - mongoutils::str::stream() << field.dottedField() - << " contains field names with leading '$' character"); + return Status(ErrorCodes::DollarPrefixedFieldName, + mongoutils::str::stream() << "The update path '" + << field.dottedField() + << "' contains an illegal field name " + "(field name starts with '$')."); } |