user1885024
user1885024

Reputation: 49

How to stop yii default error pages

I am new to Yii framework, in this i am working on small project but it throwing error pages if any errors appearing from database..

Please help me how to stop these error pages and to display some customized error page

I have been struggling to get this for some time, so any help would be greatly appreciated!!

Upvotes: 3

Views: 5382

Answers (2)

driver_by
driver_by

Reputation: 1695

To customize error page modify the view: /protected/views/site/error - "site" is your default controller.

You can change it via /protected/config/main.php:

'errorHandler'=>array(
    'errorAction'=>'myController/error',
),

And in your controller you have the action:

public function actionError()
{
    if($error=Yii::app()->errorHandler->error)
    {           
        if(Yii::app()->request->isAjaxRequest) {
        echo $error['message'];
    }
    else
        $this->render('error', $error);
    }
}

So you can do whatever you want.

Upvotes: 6

Abhi
Abhi

Reputation: 1115

try to comment the line in index.php

defined('YII_DEBUG') or define('YII_DEBUG',true);

Upvotes: 6

Related Questions