summaryrefslogtreecommitdiff
path: root/demos/blog-tutorial/samples/day5/blog/protected/BlogErrorHandler.php
diff options
context:
space:
mode:
authorxue <>2007-06-29 17:41:20 +0000
committerxue <>2007-06-29 17:41:20 +0000
commit4a9dd5c8513ed96d1e0cf43e370b170dc38fb502 (patch)
treef41bbf25ac5bbc8d0b656c3e7c087e40b09b38b1 /demos/blog-tutorial/samples/day5/blog/protected/BlogErrorHandler.php
parent2d266a7994c57e9a13cccecacf8940e11263614f (diff)
finished blog-tutorial.
Diffstat (limited to 'demos/blog-tutorial/samples/day5/blog/protected/BlogErrorHandler.php')
-rw-r--r--demos/blog-tutorial/samples/day5/blog/protected/BlogErrorHandler.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/BlogErrorHandler.php b/demos/blog-tutorial/samples/day5/blog/protected/BlogErrorHandler.php
new file mode 100644
index 00000000..56b71f8a
--- /dev/null
+++ b/demos/blog-tutorial/samples/day5/blog/protected/BlogErrorHandler.php
@@ -0,0 +1,40 @@
+<?php
+
+Prado::using('System.Exceptions.TErrorHandler');
+Prado::using('Application.BlogException');
+
+class BlogErrorHandler extends TErrorHandler
+{
+ /**
+ * Retrieves the template used for displaying external exceptions.
+ * This method overrides the parent implementation.
+ */
+ protected function getErrorTemplate($statusCode,$exception)
+ {
+ // use our own template for BlogException
+ if($exception instanceof BlogException)
+ {
+ // get the path of the error template file: protected/error.html
+ $templateFile=Prado::getPathOfNamespace('Application.error','.html');
+ return file_get_contents($templateFile);
+ }
+ else // otherwise use the template defined by PRADO
+ return parent::getErrorTemplate($statusCode,$exception);
+ }
+
+ /**
+ * Handles external error caused by end-users.
+ * This method overrides the parent implementation.
+ * It is invoked by PRADO when an external exception is thrown.
+ */
+ protected function handleExternalError($statusCode,$exception)
+ {
+ // log the error (only for BlogException)
+ if($exception instanceof BlogException)
+ Prado::log($exception->getErrorMessage(),TLogger::ERROR,'BlogApplication');
+ // call parent implementation to display the error
+ parent::handleExternalError($statusCode,$exception);
+ }
+}
+
+?> \ No newline at end of file