forked from yiisoft/yii
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:yiisoft/yii into 873-stat-relatio…
…n-scopes
- Loading branch information
Showing
3 changed files
with
19 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ | |
* {@link CApplication::getErrorHandler()}. | ||
* | ||
* @property array $error The error details. Null if there is no error. | ||
* @property Exception|null $exception exception instance. Null if there is no exception. | ||
* | ||
* @author Qiang Xue <[email protected]> | ||
* @package system.base | ||
|
@@ -82,6 +83,7 @@ class CErrorHandler extends CApplicationComponent | |
public $errorAction; | ||
|
||
private $_error; | ||
private $_exception; | ||
|
||
/** | ||
* Handles the exception/error event. | ||
|
@@ -150,6 +152,15 @@ public function getError() | |
return $this->_error; | ||
} | ||
|
||
/** | ||
* Returns the instance of the exception that is currently being handled. | ||
* @return Exception|null exception instance. Null if there is no exception. | ||
*/ | ||
public function getException() | ||
{ | ||
return $this->_exception; | ||
} | ||
|
||
/** | ||
* Handles the exception. | ||
* @param Exception $exception the exception captured | ||
|
@@ -186,6 +197,7 @@ protected function handleException($exception) | |
unset($trace[$i]['object']); | ||
} | ||
|
||
$this->_exception=$exception; | ||
$this->_error=$data=array( | ||
'code'=>($exception instanceof CHttpException)?$exception->statusCode:500, | ||
'type'=>get_class($exception), | ||
|
@@ -200,7 +212,7 @@ protected function handleException($exception) | |
if(!headers_sent()) | ||
header("HTTP/1.0 {$data['code']} ".$this->getHttpHeader($data['code'], get_class($exception))); | ||
|
||
$this->renderException($exception); | ||
$this->renderException(); | ||
} | ||
else | ||
$app->displayException($exception); | ||
|
@@ -262,6 +274,7 @@ protected function handleError($event) | |
default: | ||
$type = 'PHP error'; | ||
} | ||
$this->_exception=null; | ||
$this->_error=array( | ||
'code'=>500, | ||
'type'=>$type, | ||
|
@@ -323,10 +336,10 @@ protected function render($view,$data) | |
/** | ||
* Renders the exception information. | ||
* This method will display information from current {@link error} value. | ||
* @param Exception $exception exception object. | ||
*/ | ||
protected function renderException(Exception $exception) | ||
protected function renderException() | ||
{ | ||
$exception=$this->getException(); | ||
if($exception instanceof CHttpException || !YII_DEBUG) | ||
$this->renderError(); | ||
else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters