diff --git a/framework/yii/db/Command.php b/framework/yii/db/Command.php index a754e34..bf93a2c 100644 --- a/framework/yii/db/Command.php +++ b/framework/yii/db/Command.php @@ -146,9 +146,9 @@ class Command extends \yii\base\Component try { $this->pdoStatement = $this->db->pdo->prepare($sql); } catch (\Exception $e) { - Yii::error($e->getMessage() . "\nFailed to prepare SQL: $sql", __METHOD__); + $message = $e->getMessage() . "\nFailed to prepare SQL: $sql"; $errorInfo = $e instanceof \PDOException ? $e->errorInfo : null; - throw new Exception($e->getMessage(), $errorInfo, (int)$e->getCode(), $e); + throw new Exception($message, $errorInfo, (int)$e->getCode(), $e); } } } @@ -293,10 +293,7 @@ class Command extends \yii\base\Component return $n; } catch (\Exception $e) { Yii::endProfile($token, __METHOD__); - $message = $e->getMessage(); - - Yii::error("$message\nFailed to execute SQL: $rawSql", __METHOD__); - + $message = $e->getMessage() . "\nThe SQL being executed was: $rawSql"; $errorInfo = $e instanceof \PDOException ? $e->errorInfo : null; throw new Exception($message, $errorInfo, (int)$e->getCode(), $e); } @@ -430,8 +427,7 @@ class Command extends \yii\base\Component return $result; } catch (\Exception $e) { Yii::endProfile($token, __METHOD__); - $message = $e->getMessage(); - Yii::error("$message\nCommand::$method() failed: $rawSql", __METHOD__); + $message = $e->getMessage() . "\nThe SQL being executed was: $rawSql"; $errorInfo = $e instanceof \PDOException ? $e->errorInfo : null; throw new Exception($message, $errorInfo, (int)$e->getCode(), $e); } diff --git a/framework/yii/db/Connection.php b/framework/yii/db/Connection.php index 0dd47d8..f27698a 100644 --- a/framework/yii/db/Connection.php +++ b/framework/yii/db/Connection.php @@ -307,9 +307,7 @@ class Connection extends Component Yii::endProfile($token, __METHOD__); } catch (\PDOException $e) { Yii::endProfile($token, __METHOD__); - Yii::error("Failed to open DB connection ({$this->dsn}): " . $e->getMessage(), __METHOD__); - $message = YII_DEBUG ? 'Failed to open DB connection: ' . $e->getMessage() : 'Failed to open DB connection.'; - throw new Exception($message, $e->errorInfo, (int)$e->getCode(), $e); + throw new Exception($e->getMessage(), $e->errorInfo, (int)$e->getCode(), $e); } } } diff --git a/framework/yii/debug/panels/LogPanel.php b/framework/yii/debug/panels/LogPanel.php index b1ad63d..0f56281 100644 --- a/framework/yii/debug/panels/LogPanel.php +++ b/framework/yii/debug/panels/LogPanel.php @@ -55,7 +55,7 @@ EOD; foreach ($this->data['messages'] as $log) { list ($message, $level, $category, $time, $traces) = $log; $time = date('H:i:s.', $time) . sprintf('%03d', (int)(($time - (int)$time) * 1000)); - $message = Html::encode($message); + $message = nl2br(Html::encode($message)); if (!empty($traces)) { $message .= Html::ul($traces, array( 'class' => 'trace',