I have a problem with setting custom message instead of something like this:
"Error 500 : <h1>CDbException</h1>
… and stack trace"
I want to set user-friendly message (e.g. “You can’t delete this object. It is in relation with other objects”) when someone want delete a record which is in relation with other.
I was trying to do something like this:
public function actionDelete($id)
{
//
try
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
catch(CDbException $e)
{
throw new CDbException('Message');
}
}
But this is not working.
I also tried a way with setFlash but it also is not working.