From a876a77c054bc5cf198f29c15ddd5f7a7b8fbb05 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Tue, 18 May 2010 16:31:23 +0000
Subject: [PATCH] Better handling of missing emergency_exit.ctp

---
 index.php | 52 +++++++++++++++++++++++++++++-----------------------
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/index.php b/index.php
index 4cef375..3b7f082 100644
--- a/index.php
+++ b/index.php
@@ -132,29 +132,35 @@ final class ApplicationEntryPoint {
 				$templateInstance->assignApplicationData($appInstance);
 			} // END - if
 
-			// Assign variables
-			$templateInstance->assignVariable('message', $message);
-			$templateInstance->assignVariable('code', $code);
-			$templateInstance->assignVariable('extra', $extraData);
-			$templateInstance->assignVariable('backtrace', $backtrace);
-			$templateInstance->assignVariable('total_includes', ClassLoader::getInstance()->getTotal());
-			$templateInstance->assignVariable('total_objects', ObjectFactory::getTotal());
-			$templateInstance->assignVariable('title', $languageInstance->getMessage('emergency_exit_title'));
-
-			// Load the template
-			$templateInstance->loadCodeTemplate('emergency_exit');
-
-			// Compile the template
-			$templateInstance->compileTemplate();
-
-			// Compile all variables
-			$templateInstance->compileVariables();
-
-			// Transfer data to response
-			$templateInstance->transferToResponse($responseInstance);
-
-			// Flush the response
-			$responseInstance->flushBuffer();
+			// We only try this
+			try {
+				// Assign variables
+				$templateInstance->assignVariable('message', $message);
+				$templateInstance->assignVariable('code', $code);
+				$templateInstance->assignVariable('extra', $extraData);
+				$templateInstance->assignVariable('backtrace', $backtrace);
+				$templateInstance->assignVariable('total_includes', ClassLoader::getInstance()->getTotal());
+				$templateInstance->assignVariable('total_objects', ObjectFactory::getTotal());
+				$templateInstance->assignVariable('title', $languageInstance->getMessage('emergency_exit_title'));
+
+				// Load the template
+				$templateInstance->loadCodeTemplate('emergency_exit');
+
+				// Compile the template
+				$templateInstance->compileTemplate();
+
+				// Compile all variables
+				$templateInstance->compileVariables();
+
+				// Transfer data to response
+				$templateInstance->transferToResponse($responseInstance);
+
+				// Flush the response
+				$responseInstance->flushBuffer();
+			} catch (FileIoException $e) {
+				// Even the template 'emergency_exit' wasn't found so output both message
+				die($message . ', exception: ' . $e->getMessage());
+			}
 
 			// Good bye...
 			exit();
-- 
2.39.5