| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
Prado::using('System.Exceptions.TErrorHandler');
|
|
|
4 |
Prado::using('Application.BlogException');
|
|
|
5 |
|
|
|
6 |
class BlogErrorHandler extends TErrorHandler
|
|
|
7 |
{
|
|
|
8 |
/**
|
|
|
9 |
* Retrieves the template used for displaying external exceptions.
|
|
|
10 |
* This method overrides the parent implementation.
|
|
|
11 |
*/
|
|
|
12 |
protected function getErrorTemplate($statusCode,$exception)
|
|
|
13 |
{
|
|
|
14 |
// use our own template for BlogException
|
|
|
15 |
if($exception instanceof BlogException)
|
|
|
16 |
{
|
|
|
17 |
// get the path of the error template file: protected/error.html
|
|
|
18 |
$templateFile=Prado::getPathOfNamespace('Application.error','.html');
|
|
|
19 |
return file_get_contents($templateFile);
|
|
|
20 |
}
|
|
|
21 |
else // otherwise use the template defined by PRADO
|
|
|
22 |
return parent::getErrorTemplate($statusCode,$exception);
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Handles external error caused by end-users.
|
|
|
27 |
* This method overrides the parent implementation.
|
|
|
28 |
* It is invoked by PRADO when an external exception is thrown.
|
|
|
29 |
*/
|
|
|
30 |
protected function handleExternalError($statusCode,$exception)
|
|
|
31 |
{
|
|
|
32 |
// log the error (only for BlogException)
|
|
|
33 |
if($exception instanceof BlogException)
|
|
|
34 |
Prado::log($exception->getErrorMessage(),TLogger::ERROR,'BlogApplication');
|
|
|
35 |
// call parent implementation to display the error
|
|
|
36 |
parent::handleExternalError($statusCode,$exception);
|
|
|
37 |
}
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
?>
|