Connection::handleQueryException is a protected method and so it's not possible to invoke it from e.g. the db operation specific classes.
In #3177660: Remove public properties from StatementInterface implementations, we are stepping away from using Connection::query() for all purposes, in favour or preparing/executing Statement objects in the db operation specific classes of the drivers instead, and need to be able to handle database exceptions consistently.
For this purpose, an ExceptionHandler class in the database API was introduced, and should now be used to process database exceptions from within database driver code.
Connection::handleQueryException is deprecated.
BEFORE, from Connection::query:
...
catch (\PDOException $e) {
// Most database drivers will return NULL here, but some of them
// (e.g. the SQLite driver) may need to re-run the query, so the return
// value will be the same as for static::query().
return $this->handleQueryException($e, $query, $args, $options);
}
AFTER:
...
catch (\Exception $e) {
// Most database drivers will return NULL here, but some of them
// (e.g. the SQLite driver) may need to re-run the query, so the return
// value will be the same as for static::query().
...
return $this->exceptionHandler()->handleExecutionException($e, $stmt, $args, $options);
...
}