Open
Description
This issue has originally been reported by @timfayz at yiisoft/yii2#2503.
Moved here by @cebe.
Hello, I can't access to message
property of exception's object. Is in normal?
My simple code:
#SiteController.php
#I changed errorHandler action to site/error in configurations.
public function actionError()
{
$this->layout = 'container';
if (\Yii::$app->exception !== null) {
return $this->render('error', ['exception' => \Yii::$app->exception]);
}
}
public function actionPage($view = 'index')
{
try {
return $this->render('site/page/'.$view);
} catch (InvalidParamException $e) {
throw new HttpException(404, 'Страница не найдена');
}
}
When I go to nonexist page, I get the following:
yii\web\HttpException Object
(
[statusCode] => 404
[message:protected] => Страница не найдена #custom message naturally inaccessible
It means that I can't insert $exception->message
into view file.