improve error message when specifying invalid schema
This commit is contained in:
parent
850e3a4090
commit
bf488274a3
|
@ -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<ObjectSchemaValidationException> 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<ObjectSchemaValidationException> 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) :
|
||||
|
|
|
@ -160,6 +160,11 @@ namespace realm {
|
|||
std::vector<ObjectSchemaValidationException> m_validation_errors;
|
||||
};
|
||||
|
||||
class SchemaUpdateValidationException : public SchemaValidationException {
|
||||
public:
|
||||
SchemaUpdateValidationException(std::vector<ObjectSchemaValidationException> const& errors);
|
||||
};
|
||||
|
||||
class ObjectSchemaValidationException : public ObjectStoreException {
|
||||
public:
|
||||
ObjectSchemaValidationException(std::string const& object_type) : m_object_type(object_type) {}
|
||||
|
|
Loading…
Reference in New Issue