summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/doc_validation_error.h
diff options
context:
space:
mode:
authorMihai Andrei <mihai.andrei@10gen.com>2020-07-02 19:21:35 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-07 13:38:05 +0000
commite87f6f53c58a75229b40fff7b32de202f2dcccc7 (patch)
treeeafb77ccd24ee11879f904c042eec41e4a3ad76e /src/mongo/db/matcher/doc_validation_error.h
parentff4465b905b331fc82edb8194092917ad0c7255f (diff)
downloadmongo-e87f6f53c58a75229b40fff7b32de202f2dcccc7.tar.gz
SERVER-48781 Introduce 'DocumentValidationErrorExtraInfo' and shell support for document validation errors
Diffstat (limited to 'src/mongo/db/matcher/doc_validation_error.h')
-rw-r--r--src/mongo/db/matcher/doc_validation_error.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mongo/db/matcher/doc_validation_error.h b/src/mongo/db/matcher/doc_validation_error.h
index 30d29be8516..ae632080179 100644
--- a/src/mongo/db/matcher/doc_validation_error.h
+++ b/src/mongo/db/matcher/doc_validation_error.h
@@ -29,14 +29,29 @@
#pragma once
+#include "mongo/base/error_extra_info.h"
#include "mongo/db/matcher/expression.h"
namespace mongo::doc_validation_error {
/**
+ * Represents information about a document validation error.
+ */
+class DocumentValidationFailureInfo final : public ErrorExtraInfo {
+public:
+ static constexpr auto code = ErrorCodes::DocumentValidationFailure;
+ static std::shared_ptr<const ErrorExtraInfo> parse(const BSONObj& obj);
+ explicit DocumentValidationFailureInfo(const BSONObj& err) : _details(err.getOwned()) {}
+ const BSONObj& getDetails() const;
+ void serialize(BSONObjBuilder* bob) const override;
+
+private:
+ BSONObj _details;
+};
+
+/**
* Given a pointer to a MatchExpression corresponding to a collection's validator expression and a
* reference to a BSONObj corresponding to the document that failed to match against the validator
* expression, returns a BSONObj that describes why 'doc' failed to match against 'validatorExpr'.
*/
BSONObj generateError(const MatchExpression& validatorExpr, const BSONObj& doc);
-
} // namespace mongo::doc_validation_error \ No newline at end of file