Custom Error Handler Implementation

Hi,

I have followed the custom error handling guidelines as here: http://www.yiiframework.com/doc/guide/1.1/en/topics.error to create an ErrorController as in Zend.

The /controllers/ErrorController.php code:

class ErrorController extends CController

{

/**


 * This is the default 'index' action that is invoked


 * It handles uncaught exceptions


 */


public function actionIndex()


{


if($error=Yii::app()->errorHandler->error)


	{


		if(Yii::app()->request->isAjaxRequest)


			echo $error['message'];


		else


			$this->render('index', $error);


	}


}

}

The /views/error/index.php view:

/* @var $this ErrorController */

/* @var $error array */

$this->pageTitle=Yii::app()->name . ’ - Error’;

$this->breadcrumbs=array(

'Error',

);

?>

<h2>Error <?php echo $code; ?></h2>

<div class="error">

<?php echo CHtml::encode($message); ?>

</div>

The configuration file settings:

‘errorHandler’=>array(

		// use 'error/index' action to display errors


		'errorAction'=&gt;'error/index',


	),

In a controller I’ve inserted

trigger_error("Test for custom error processing", E_USER_ERROR);

but the result is that this error is still shown in the standard CErrorHandler view. Moreover, the stack trace lists CErrorHandler rather than to my ErrorController, though is defined in the config file.