summaryrefslogtreecommitdiff
path: root/demos/blog/protected/Common/BlogErrorHandler.php
blob: bc2370800c210acb16bb3f9854e98710451ebac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
 * BlogErrorHandler class file
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @link https://github.com/pradosoft/prado
 * @copyright Copyright &copy; 2006-2016 The PRADO Group
 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
 */

Prado::using('System.Exceptions.TErrorHandler');
Prado::using('Application.Common.BlogException');

/**
 * BlogErrorHandler class
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @link https://github.com/pradosoft/prado
 * @copyright Copyright &copy; 2006-2016 The PRADO Group
 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
 */
class BlogErrorHandler extends TErrorHandler
{
	/**
	 * Displays error to the client user.
	 * THttpException and errors happened when the application is in <b>Debug</b>
	 * mode will be displayed to the client user.
	 * @param integer response status code
	 * @param Exception exception instance
	 */
	protected function handleExternalError($statusCode,$exception)
	{
		if($exception instanceof BlogException)
		{
			$message=$exception->getMessage();
			Prado::log($message,TLogger::ERROR,'BlogApplication');
			$message=urldecode($this->getApplication()->getSecurityManager()->hashData($message));
			$this->Response->redirect($this->Service->constructUrl('ErrorReport',array('msg'=>$message),false));
		}
		else
			parent::handleExternalError($statusCode,$exception);
	}
}