Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access to message property of HttpException. #44

Open
yii-bot opened this issue Jan 24, 2016 · 2 comments
Open

Can't access to message property of HttpException. #44

yii-bot opened this issue Jan 24, 2016 · 2 comments

Comments

@yii-bot
Copy link

yii-bot commented Jan 24, 2016

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.

@cebe cebe added the type:bug Bug label Jan 24, 2016
@cebe cebe added the type:enhancement Enhancement label Nov 22, 2016
@cebe cebe modified the milestones: 2.0.7, 2.0.8 Nov 22, 2016
@samdark samdark removed this from the 2.0.7 milestone Feb 15, 2019
@arogachev
Copy link
Contributor

arogachev commented Nov 29, 2021

It's been a while... But is it really necessary @samdark? I think the link to PHP docs in inheritance section is enough.

Screenshot 2021-11-29 at 17-48-09 Exception, yii base Exception

@arogachev
Copy link
Contributor

Otherwise we need to discuss what's exactly needs to be done here.

@samdark samdark closed this as completed Nov 30, 2021
@samdark samdark reopened this Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants