Commit 05f1cfa3 authored by dazz's avatar dazz Committed by Benjamin Eberlei

[DBAL-407] Be more specific on error code condition while detecting

parent 18c3c175
......@@ -120,8 +120,9 @@ class Driver implements \Doctrine\DBAL\Driver
if (strpos($exception->getMessage(), 'Cannot delete or update a parent row: a foreign key constraint fails') !== false) {
return DBALException::ERROR_FOREIGN_KEY_CONSTRAINT;
}
if (strpos($exception->getMessage(), 'Duplicate entry') !== false) {
return DBALException::ERROR_DUPLICATE_KEY;
}
case '42S02':
return DBALException::ERROR_UNKNOWN_TABLE;
case '42S01':
......
......@@ -121,7 +121,9 @@ class Driver implements \Doctrine\DBAL\Driver
{
switch ($exception->getCode()) {
case 23000:
if (strpos($exception->getMessage(), 'must be unique') !== false) {
return DBALException::ERROR_DUPLICATE_KEY;
}
case 'HY000':
if (strpos($exception->getMessage(), 'no such table:') !== false) {
return DBALException::ERROR_UNKNOWN_TABLE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment