Commit b1d94e5c by Alexander Makarov

Removed unnecessary instance check, fixed Sphinx schema

parent ca465eae
...@@ -60,6 +60,12 @@ class Schema extends Object ...@@ -60,6 +60,12 @@ class Schema extends Object
private $_builder; private $_builder;
/** /**
* @var array map of DB errors and corresponding exceptions
* If left part is found in DB error message exception class from the right part is used.
*/
public $exceptionMap = [];
/**
* @var array mapping from physical column types (keys) to abstract column types (values) * @var array mapping from physical column types (keys) to abstract column types (values)
*/ */
public $typeMap = [ public $typeMap = [
......
...@@ -782,12 +782,10 @@ class Command extends \yii\base\Component ...@@ -782,12 +782,10 @@ class Command extends \yii\base\Component
} else { } else {
$exceptionClass = '\yii\db\Exception'; $exceptionClass = '\yii\db\Exception';
$schema = $this->db->getSchema(); $schema = $this->db->getSchema();
if ($schema instanceof Schema) { $exceptionMap = $schema->exceptionMap;
$exceptionMap = $schema->exceptionMap; foreach ($exceptionMap as $error => $class) {
foreach ($exceptionMap as $error => $class) { if (strpos($e->getMessage(), $error) !== false) {
if (strpos($e->getMessage(), $error) !== false) { $exceptionClass = $class;
$exceptionClass = $class;
}
} }
} }
......
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