Browse Source
- Correct exit code for require errors in CLI mode. It was 0 even in case of error. - Solved handling fatals and displaying custom error template w/o output buffering. - If XDEBUG is available, error screen will display trace (implementation inspired by Kohana and Nette). - Added ErrorException to store/display type of the error and user-friendly messages. - Fatals are still logged in PHP log. - Turned off native display_errors since we're now catching all errors. - Added reserving memory (256kb) . Can be removed safely. In case of removal we're losing only memory exhausted error when allocating last very small chunk of memory. - Properly handled errors in __toString (exception can't be thrown in this case). - In the YII_DEBUG===false mode it's bad to display exception name even in page title. - In the YII_DEBUG===true mode it's still useful to get user-friendly message additionally to exception name.tags/2.0.0-beta
Alexander Makarov
12 years ago
5 changed files with 123 additions and 27 deletions
@ -0,0 +1,47 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* ErrorException class file. |
||||||
|
* |
||||||
|
* @link http://www.yiiframework.com/ |
||||||
|
* @copyright Copyright © 2008 Yii Software LLC |
||||||
|
* @license http://www.yiiframework.com/license/ |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace yii\base; |
||||||
|
|
||||||
|
/** |
||||||
|
* ErrorException represents a PHP error. |
||||||
|
* |
||||||
|
* @author Alexander Makarov <sam@rmcreative.ru> |
||||||
|
* @since 2.0 |
||||||
|
*/ |
||||||
|
class ErrorException extends \ErrorException |
||||||
|
{ |
||||||
|
public static function getFatalCodes() |
||||||
|
{ |
||||||
|
return array(E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return string the user-friendly name of this exception |
||||||
|
*/ |
||||||
|
public function getName() |
||||||
|
{ |
||||||
|
$names = array( |
||||||
|
E_ERROR => \Yii::t('yii|Fatal Error'), |
||||||
|
E_PARSE => \Yii::t('yii|Parse Error'), |
||||||
|
E_CORE_ERROR => \Yii::t('yii|Core Error'), |
||||||
|
E_COMPILE_ERROR => \Yii::t('yii|Compile Error'), |
||||||
|
E_USER_ERROR => \Yii::t('yii|User Error'), |
||||||
|
E_WARNING => \Yii::t('yii|Warning'), |
||||||
|
E_CORE_WARNING => \Yii::t('yii|Core Warning'), |
||||||
|
E_COMPILE_WARNING => \Yii::t('yii|Compile Warning'), |
||||||
|
E_USER_WARNING => \Yii::t('yii|User Warning'), |
||||||
|
E_STRICT => \Yii::t('yii|Strict'), |
||||||
|
E_NOTICE => \Yii::t('yii|Notice'), |
||||||
|
E_RECOVERABLE_ERROR => \Yii::t('yii|Recoverable Error'), |
||||||
|
E_DEPRECATED => \Yii::t('yii|Deprecated'), |
||||||
|
); |
||||||
|
return isset($names[$this->getCode()]) ? $names[$this->getCode()] : \Yii::t('yii|Error'); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue