Commit 2c15ad9e authored by alexpott's avatar alexpott

Issue #2542422 by jhedstrom: Improve DX of exceptions thrown in SqlContentEntityStorageSchema

parent 184d4b42
......@@ -285,7 +285,7 @@ public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeI
// If a migration is required, we can't proceed.
if ($this->requiresEntityDataMigration($entity_type, $original)) {
throw new EntityStorageException('The SQL storage cannot change the schema for an existing entity type with data.');
throw new EntityStorageException('The SQL storage cannot change the schema for an existing entity type (' . $entity_type->id() . ') with data.');
}
// If we have no data just recreate the entity schema from scratch.
......@@ -415,7 +415,7 @@ public function onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $
// @todo Add purging to all fields: https://www.drupal.org/node/2282119.
try {
if (!($storage_definition instanceof FieldStorageConfigInterface) && $this->storage->countFieldData($storage_definition, TRUE)) {
throw new FieldStorageDefinitionUpdateForbiddenException('Unable to delete a field with data that cannot be purged.');
throw new FieldStorageDefinitionUpdateForbiddenException('Unable to delete a field (' . $storage_definition->getName() . ' in ' . $storage_definition->getTargetEntityTypeId() . ' entity) with data that cannot be purged.');
}
}
catch (DatabaseException $e) {
......@@ -1268,7 +1268,7 @@ protected function updateDedicatedTableSchema(FieldStorageDefinitionInterface $s
}
else {
if ($storage_definition->getColumns() != $original->getColumns()) {
throw new FieldStorageDefinitionUpdateForbiddenException("The SQL storage cannot change the schema for an existing field with data.");
throw new FieldStorageDefinitionUpdateForbiddenException('The SQL storage cannot change the schema for an existing field (' . $storage_definition->getName() . ' in ' . $storage_definition->getTargetEntityTypeId() . ' entity) with data.');
}
// There is data, so there are no column changes. Drop all the prior
// indexes and create all the new ones, except for all the priors that
......@@ -1357,7 +1357,7 @@ protected function updateSharedTableSchema(FieldStorageDefinitionInterface $stor
}
else {
if ($storage_definition->getColumns() != $original->getColumns()) {
throw new FieldStorageDefinitionUpdateForbiddenException("The SQL storage cannot change the schema for an existing field with data.");
throw new FieldStorageDefinitionUpdateForbiddenException('The SQL storage cannot change the schema for an existing field (' . $storage_definition->getName() . ' in ' . $storage_definition->getTargetEntityTypeId() . ' entity) with data.');
}
$updated_field_name = $storage_definition->getName();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment