function DatabaseStorage::catchException

Same name in other branches
  1. 9 core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php \Drupal\Core\KeyValueStore\DatabaseStorage::catchException()
  2. 11.x core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php \Drupal\Core\KeyValueStore\DatabaseStorage::catchException()

Act on an exception when the table might not have been created.

If the table does not yet exist, that's fine, but if the table exists and yet the query failed, then the exception needs to propagate if it is not a DatabaseException. Due to race conditions it is possible that another request has created the table in the meantime. Therefore we can not rethrow for any database exception.

Parameters

\Exception $e: The exception.

Throws

\Exception

8 calls to DatabaseStorage::catchException()
DatabaseStorage::deleteAll in core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php
DatabaseStorage::deleteMultiple in core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php
DatabaseStorage::getAll in core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php
DatabaseStorage::has in core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php
DatabaseStorage::rename in core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php

... See full list

File

core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php, line 284

Class

DatabaseStorage
Defines a default key/value store implementation.

Namespace

Drupal\Core\KeyValueStore

Code

protected function catchException(\Exception $e) {
    if (!$e instanceof DatabaseException && $this->connection
        ->schema()
        ->tableExists($this->table)) {
        throw $e;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.