How to set errorAction for module?

I’m trying to set a different error action for an admin module. I’ve tried in various ways (see below) but cannot get it to work. Any ideas?




class AdminModule extends CWebModule

{

	public function init()

	{

		// import the module-level models and components

		$this->setImport(array(

			'admin.models.*',

			'admin.components.*',

		));

		

		$this->setComponents(array(

			'errorHandler'=>array(

					'errorAction'=>'/admin/default/error'

				)

		));

	}






class AdminModule extends CWebModule

{

	public function init()

	{

		// import the module-level models and components

		$this->setImport(array(

			'admin.models.*',

			'admin.components.*',

		));

		

		Yii::app()->errorHandler->errorAction='/admin/default/error';

		

	}

	

}



Do it like this:


public function init()

{

	parent::init();

	Yii::app()->setComponents(array(

		'errorHandler'=>array(

			'errorAction'=>'admin/default/error',

		),

	));

		

	// import the module-level models and components

	$this->setImport(array(

		'admin.models.*',

		'admin.components.*',

	));

}

Thanks for this, it now works!

AdminModule.php add init() as below




 


	parent::init();

		Yii::app()->setComponents(array(

		'errorHandler'=>array(

		'errorAction'=>'admin/default/error',

		),

		));