Yii Framework Forum: Capplication Handleerror() Ends App - Yii Framework Forum

Jump to content

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

Capplication Handleerror() Ends App Rate Topic: -----

#1 User is offline   G. Miliotis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 16-February 13

Posted 16 February 2013 - 07:35 AM

I don't see why the handleError() method of CApplication has to always terminate the application. For example, when uploading a file and the move_uploaded_file function fails, it is not good to just blow up with a "WARNING, failed to move etc.". I have registered an error event and I want this handled gracefully in my controller, showing form validation results normally.

So I request that handleError() provide a mechanism of not always terminating the app. Probably an attribute in CApplication of some sort of a callback filtering the error. For example, my 'terminateOrNot' callback could whitelist move_uploaded_file based on stack trace.

Just for reference, I have hacked yii (horribly) to enable event handling for this function. This is my main index.php.


// change the following paths if necessary

// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


class MyYiiBase extends YiiBase {
	public static function createMyWebApplication($config=null)
		return self::createApplication('MyWebApplication',$config);

class MyWebApplication extends CWebApplication {
	public function end($status=0,$exit=true)

		if ( $caller['function'] == 'handleError' &&
			$caller['class'] == 'CApplication' &&
			$caller2['function'] == 'move_uploaded_file' ) {
			$exit = false; //block ending the application if called from handleError about move uploaded file
		return CWebApplication::end($status,$exit);

class Yii extends MyYiiBase



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