diff --git a/src/object_store.cpp b/src/object_store.cpp index 56dd3d84..cf6025a6 100644 --- a/src/object_store.cpp +++ b/src/object_store.cpp @@ -169,7 +169,7 @@ void ObjectStore::verify_schema(Schema const& actual_schema, Schema& target_sche errors.insert(errors.end(), more_errors.begin(), more_errors.end()); } if (errors.size()) { - throw SchemaValidationException(errors); + throw SchemaUpdateValidationException(errors); } } @@ -521,6 +521,16 @@ DuplicatePrimaryKeyValueException::DuplicatePrimaryKeyValueException(std::string SchemaValidationException::SchemaValidationException(std::vector const& errors) : m_validation_errors(errors) +{ + m_what ="The following errors were encountered during schema validation: "; + for (auto const& error : errors) { + m_what += std::string("\n- ") + error.what(); + } +} + + +SchemaUpdateValidationException::SchemaUpdateValidationException(std::vector const& errors) : + SchemaValidationException(errors) { m_what ="Migration is required due to the following errors: "; for (auto const& error : errors) { @@ -560,7 +570,7 @@ InvalidNullabilityException::InvalidNullabilityException(std::string const& obje MissingObjectTypeException::MissingObjectTypeException(std::string const& object_type, Property const& property) : ObjectSchemaPropertyException(object_type, property) { - m_what = "Target type '" + property.object_type + "' doesn't exist for property '" + property.name + "'."; + m_what = "Property '" + property.name + "' has an invalid type '" + property.object_type + "'.'"; } MismatchedPropertiesException::MismatchedPropertiesException(std::string const& object_type, Property const& old_property, Property const& new_property) : diff --git a/src/object_store.hpp b/src/object_store.hpp index bfbc6acc..e538fdc7 100644 --- a/src/object_store.hpp +++ b/src/object_store.hpp @@ -159,6 +159,11 @@ namespace realm { private: std::vector m_validation_errors; }; + + class SchemaUpdateValidationException : public SchemaValidationException { + public: + SchemaUpdateValidationException(std::vector const& errors); + }; class ObjectSchemaValidationException : public ObjectStoreException { public: