mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-23 04:00:23 +08:00
avoid throwing the same type of new db exception.
This commit is contained in:
@ -278,11 +278,15 @@ class Command extends \yii\base\Component
|
|||||||
return $n;
|
return $n;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Yii::endProfile($token, __METHOD__);
|
Yii::endProfile($token, __METHOD__);
|
||||||
|
if ($e instanceof Exception) {
|
||||||
|
throw $e;
|
||||||
|
} else {
|
||||||
$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;
|
||||||
throw new Exception($message, $errorInfo, (int)$e->getCode(), $e);
|
throw new Exception($message, $errorInfo, (int)$e->getCode(), $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL statement and returns query result.
|
* Executes the SQL statement and returns query result.
|
||||||
@ -411,11 +415,15 @@ class Command extends \yii\base\Component
|
|||||||
return $result;
|
return $result;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Yii::endProfile($token, __METHOD__);
|
Yii::endProfile($token, __METHOD__);
|
||||||
|
if ($e instanceof Exception) {
|
||||||
|
throw $e;
|
||||||
|
} else {
|
||||||
$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;
|
||||||
throw new Exception($message, $errorInfo, (int)$e->getCode(), $e);
|
throw new Exception($message, $errorInfo, (int)$e->getCode(), $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an INSERT command.
|
* Creates an INSERT command.
|
||||||
|
Reference in New Issue
Block a user