W3cubDocs

/Drupal 8

protected function SqlContentEntityStorage::wrapSchemaException

protected SqlContentEntityStorage::wrapSchemaException(callable $callback)

Wraps a database schema exception into an entity storage exception.

Parameters

callable $callback: The callback to be executed.

Throws

\Drupal\Core\Entity\EntityStorageException When a database schema exception is thrown.

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php, line 1449

Class

SqlContentEntityStorage
A content entity database storage implementation.

Namespace

Drupal\Core\Entity\Sql

Code

protected function wrapSchemaException(callable $callback) {
  $message = 'Exception thrown while performing a schema update.';
  try {
    $callback();
  }
  catch (SchemaException $e) {
    $message .= ' ' . $e->getMessage();
    throw new EntityStorageException($message, 0, $e);
  }
  catch (DatabaseExceptionWrapper $e) {
    $message .= ' ' . $e->getMessage();
    throw new EntityStorageException($message, 0, $e);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!SqlContentEntityStorage.php/function/SqlContentEntityStorage::wrapSchemaException/8.1.x