Yii Framework Forum: Exception Error - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Exception Error Rate Topic: -----

#1 User is offline   karthik123 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 23-November 12
  • Location:Tamilnadu,coimbatore,India

Posted 27 January 2013 - 11:42 PM

How to handle sql custom error message ( raiserror ) in yii framework with linux os. Now Yii throw that message as php warning. How to over come this error


this is my code

$sql = "[sp_Language] :Language_Code, :Language_Name, :Active, :Disp_Order, :Action ";
$command = $this->createCommand($sql);
$command->bindParam(":Language_Code", $languageCode, PDO::PARAM_INT);
$command->bindParam(":Language_Name", $language, PDO::PARAM_STR);
$command->bindParam(":Active", $active, PDO::PARAM_STR);
$command->bindParam(":Disp_Order", $displayOrder, PDO::PARAM_INT);
$command->bindParam(":Action", $action, PDO::PARAM_INT);
try
{
$this->msg = '';
$command->queryAll();
}
catch(CDbException $ex)
{
$this->msg = substr($ex->errorInfo[2],0,-30);
//throw new ExceptionClass('tet');

}


Thanks in advance

Attached File(s)


0

#2 User is offline   karthik123 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 23-November 12
  • Location:Tamilnadu,coimbatore,India

Posted 28 January 2013 - 06:20 AM

View Postkarthik123, on 27 January 2013 - 11:42 PM, said:

How to handle sql custom error message ( raiserror ) in yii framework with linux os. Now Yii throw that message as php warning. How to over come this error


this is my code

$sql = "[sp_Language] :Language_Code, :Language_Name, :Active, :Disp_Order, :Action ";
$command = $this->createCommand($sql);
$command->bindParam(":Language_Code", $languageCode, PDO::PARAM_INT);
$command->bindParam(":Language_Name", $language, PDO::PARAM_STR);
$command->bindParam(":Active", $active, PDO::PARAM_STR);
$command->bindParam(":Disp_Order", $displayOrder, PDO::PARAM_INT);
$command->bindParam(":Action", $action, PDO::PARAM_INT);
try
{
$this->msg = '';
$command->queryAll();
}
catch(CDbException $ex)
{
$this->msg = substr($ex->errorInfo[2],0,-30);
//throw new ExceptionClass('tet');

}


Thanks in advance





Any one help me am new one in yii frame
0

#3 User is offline   CPzee 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 59
  • Joined: 11-November 11
  • Location:Sri Lanka

Posted 20 February 2013 - 04:20 AM

View Postkarthik123, on 28 January 2013 - 06:20 AM, said:

Any one help me am new one in yii frame


Hi,
Don't know actually is there any way to get rid of this.But how I handle those exceptions from the php function set_error_handler

EG:

$old_error_handler = set_error_handler(array('ClassName', 'handleErrors'));

try
{
	if (.................)
	{
		..............................
		..............................
	}
	else
	{
		..............................
		..............................
	}

	............................

	if ($model->save())	
	{
		..............................
	}
}
catch (CDbException $ex)
{
         ..................................
	throw new Exception(".....................");
}
catch (Exception $ex)
{
	....................
 	throw new Exception($ex->getMessage(), $ex->getCode());
}


set_error_handler($old_error_handler);

Found anything useful???? Pls click +
Ubuntu 12.04--PHP 5.3.10(Yii v1.1.13)
0

#4 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 513
  • Joined: 08-August 09

Posted 21 February 2013 - 05:44 AM

Have you read the guide:
http://www.yiiframew...en/topics.error ?

Usually, all you need is to disable debug mode in production environment
and to use something like
        'errorHandler' => array(
            'errorAction' => (YII_DEBUG ? null : 'site/error'),
        ),

in your config file to handle error in a desired method.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users