Commit 7764086c by Alexander Makarov

IntegrityException should be thrown for relational DBs only

parent d1ec2a02
...@@ -781,12 +781,15 @@ class Command extends \yii\base\Component ...@@ -781,12 +781,15 @@ class Command extends \yii\base\Component
throw $e; throw $e;
} else { } else {
$exceptionClass = '\yii\db\Exception'; $exceptionClass = '\yii\db\Exception';
$errorMap = $this->db->getSchema()->errorMap; $schema = $this->db->getSchema();
foreach ($errorMap as $error => $class) { if ($schema instanceof Schema) {
$exceptionMap = $schema->exceptionMap;
foreach ($exceptionMap as $error => $class) {
if (strpos($e->getMessage(), $error) !== false) { if (strpos($e->getMessage(), $error) !== false) {
$exceptionClass = $class; $exceptionClass = $class;
} }
} }
}
$message = $e->getMessage() . "\nThe SQL being executed was: $rawSql"; $message = $e->getMessage() . "\nThe SQL being executed was: $rawSql";
$errorInfo = $e instanceof \PDOException ? $e->errorInfo : null; $errorInfo = $e instanceof \PDOException ? $e->errorInfo : null;
......
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