Skip to content

Commit 9afa8b4

Browse files
committed
Added new types of Exception: SqlLockException, LockWaitTimeoutExceededException
1 parent 343060d commit 9afa8b4

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

src/Databases/MySQL/MySQLExceptionInterpreter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Kir\MySQL\Databases\MySQL;
33

4+
use Kir\MySQL\Exceptions\LockWaitTimeoutExceededException;
45
use Kir\MySQL\Exceptions\SqlDeadLockException;
56
use PDO;
67
use PDOException;
@@ -27,6 +28,9 @@ public function throwMoreConcreteException(PDOException $exception) {
2728
if($code === 1213) {
2829
throw new SqlDeadLockException($message, $code, $exception);
2930
}
31+
if($code === 1205) {
32+
throw new LockWaitTimeoutExceededException($message, $code, $exception);
33+
}
3034
throw $exception;
3135
}
3236
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
namespace Kir\MySQL\Exceptions;
3+
4+
class LockWaitTimeoutExceededException extends SqlLockException {
5+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22
namespace Kir\MySQL\Exceptions;
33

4-
class SqlDeadLockException extends SqlException {
4+
class SqlDeadLockException extends SqlLockException {
55
}

src/Exceptions/SqlLockException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
namespace Kir\MySQL\Exceptions;
3+
4+
class SqlLockException extends SqlException {
5+
}

0 commit comments

Comments
 (0)