Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ExceptionHandler.php

function ExceptionHandler::handleStatementException

Handles exceptions thrown during the preparation of statement objects.

Parameters

\Exception $exception: The exception to be handled.

string $sql: The SQL statement that was requested to be prepared.

array $options: An associative array of options to control how the database operation is run.

Throws

\Drupal\Core\Database\DatabaseExceptionWrapper

File

core/lib/Drupal/Core/Database/ExceptionHandler.php, line 28

Class

ExceptionHandler
Base Database exception handler class.

Namespace

Drupal\Core\Database

Code

public function handleStatementException(\Exception $exception, string $sql, array $options = []) : void {
    if ($exception instanceof \PDOException) {
        // Wrap the exception in another exception, because PHP does not allow
        // overriding Exception::getMessage(). Its message is the extra database
        // debug information.
        $message = $exception->getMessage() . ": " . $sql . "; ";
        throw new DatabaseExceptionWrapper($message, 0, $exception);
    }
    throw $exception;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal