Fix #19454: Fix PDO exception code not properly passed to yii\db\Exception

This commit is contained in:
Roguyt
2022-07-07 17:24:06 +02:00
committed by GitHub
parent 827db6c90e
commit dcb0750587
3 changed files with 4 additions and 3 deletions

View File

@ -37,6 +37,7 @@ Yii Framework 2 Change Log
- Bug #19400: Fix passing null in `yii\web\Response::redirect()` (bizley)
- Enh #19437: Add support to specify request port by trusted proxies in `\yii\web\Request::getServerPort()` (rhertogh)
- Bug #19445: Fix caching in `yii\i18n\Formatter::getUnitMessage()` (WinterSilence)
- Bug #19454: Fix PDO exception code not properly passed to `yii\db\Exception` (Roguyt)
2.0.45 February 11, 2022

View File

@ -269,10 +269,10 @@ class Command extends Component
} catch (\Exception $e) {
$message = $e->getMessage() . "\nFailed to prepare SQL: $sql";
$errorInfo = $e instanceof \PDOException ? $e->errorInfo : null;
throw new Exception($message, $errorInfo, (int) $e->getCode(), $e);
throw new Exception($message, $errorInfo, $e->getCode(), $e);
} catch (\Throwable $e) {
$message = $e->getMessage() . "\nFailed to prepare SQL: $sql";
throw new Exception($message, null, (int) $e->getCode(), $e);
throw new Exception($message, null, $e->getCode(), $e);
}
}

View File

@ -644,7 +644,7 @@ class Connection extends Component
Yii::endProfile($token, __METHOD__);
}
throw new Exception($e->getMessage(), $e->errorInfo, (int) $e->getCode(), $e);
throw new Exception($e->getMessage(), $e->errorInfo, $e->getCode(), $e);
}
}