Catch Exceptions In Action

I have de following code and I would like to catch exceptions with a try catch codeblock, but yii takes control over the exepction before, how can I catch these exceptions?




class SalidaAction extends CAction {


   public function run($id = null) {

      try {


         if ($id === null) {

            $model = new FinanzasSalida();

            $model->fecha = date('Y-m-d');

         } else {

            $model = FinanzasSalida::model()->findByPk($id);

         }




         // Lista de lugares donde se hacen consultas

         $consultorios = EmpresaConsultorio::model()->findAll();

         $lista_consultorios = CHtml::listData($consultorios, 'id_consultorio', 'lugar');


         if (isset($_POST['FinanzasSalida'])) {

            $model->attributes = $_POST['FinanzasSalida'];

            if ($model->save()) {

               $urlReturn = Yii::app()->createUrl('/finanzas/salidas/index');

               $this->controller->redirect($urlReturn);

            }

         }

      } catch (CException $ex) {

         var_dump($ex);

         Yii::app()->end();

      }


      $this->controller->render("/salida", array(

         'model' => $model,

         'lista_consultorios' => $lista_consultorios,

      ));

   }


}



Depends on the type of the exception. Try changing CException into Exception instead.