How To Get A User Friendly Error Instead Of A Raw Code Exception "the Right Way"


i have a model method upload file, and when the method crashes it throws an exception. What happens is that i end up getting this:

What can i do to just display a user friendly error message the "right way" istead of this coding exception thing?

my model:

public function uploadFile(){


		$uploadedFile = CUploadedFile::getInstance($this,'path_to_file');




				$this->path_to_file = Constantes::path_to_file.$uploadedFile->name;

				//save Thumb

				$image = new EasyImage(Constantes::path_to_file.$uploadedFile->name);

				$image->resize(100, 100);


			}catch(Exception $e){

				throw new Exception("Erro ao fazer upload da imagem");




the controller snippet of the called method:



			$model = new ComentarioDeComentario();



			$model->conteudo = strip_tags($_POST['ComentarioDeComentario']['conteudo']);

			$model->comentario_id = $_POST['ComentarioDeComentario']['comentario_id'];

			$model->user_id = Yii::app()->user->getState('id');







I think you deleted error action from your siteController.

You need to create error action first

Then change config/main.php


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



hope this helps!!!

Just set debug to false :)

… and, of course, write all error messages in Norwegian…

Norwegian errors will end up not being so friendly after all, kkk.

The debug false worked fine! I forgot about that, thks!

You are right, of course.

More seriously, I guess you already know, but I thought I’d mention that you can customize the error page located in views\site\error.php

I have seen some great examples of helpful error pages.