feat(db): add mapping for lock wait timeout

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
pull/45559/head
Daniel Kesselberg 11 months ago
parent b7b2966ce2
commit 3fb0aa40cd
No known key found for this signature in database
GPG Key ID: 36E3664E099D0614
  1. 4
      lib/private/DB/Exceptions/DbalException.php
  2. 7
      lib/public/DB/Exception.php
  3. 2
      tests/lib/DB/Exception/DbalExceptionTest.php

@ -17,6 +17,7 @@ use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
use Doctrine\DBAL\Exception\LockWaitTimeoutException;
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
use Doctrine\DBAL\Exception\RetryableException;
@ -82,6 +83,9 @@ class DbalException extends Exception {
/**
* Other server errors
*/
if ($this->original instanceof LockWaitTimeoutException) {
return parent::REASON_LOCK_WAIT_TIMEOUT;
}
if ($this->original instanceof DatabaseObjectExistsException) {
return parent::REASON_DATABASE_OBJECT_EXISTS;
}

@ -120,6 +120,13 @@ class Exception extends BaseException {
*/
public const REASON_UNIQUE_CONSTRAINT_VIOLATION = 14;
/**
* The lock wait timeout was exceeded
*
* @since 30.0.0
*/
public const REASON_LOCK_WAIT_TIMEOUT = 15;
/**
* @return int|null
* @psalm-return Exception::REASON_*

@ -17,6 +17,7 @@ use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
use Doctrine\DBAL\Exception\LockWaitTimeoutException;
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
use Doctrine\DBAL\Exception\ServerException;
@ -45,6 +46,7 @@ class DbalExceptionTest extends \Test\TestCase {
public function dataDriverException(): array {
return [
[LockWaitTimeoutException::class, DbalException::REASON_LOCK_WAIT_TIMEOUT],
[ForeignKeyConstraintViolationException::class, DbalException::REASON_FOREIGN_KEY_VIOLATION],
[NotNullConstraintViolationException::class, DbalException::REASON_NOT_NULL_CONSTRAINT_VIOLATION],
[UniqueConstraintViolationException::class, DbalException::REASON_UNIQUE_CONSTRAINT_VIOLATION],

Loading…
Cancel
Save