Переглянути джерело

Template class now uses FormattedException instead of RuntimeException

Taddeus Kroes 13 роки тому
батько
коміт
d379120eff
2 змінених файлів з 6 додано та 6 видалено
  1. 5 5
      template.php
  2. 1 1
      tests/test_template.php

+ 5 - 5
template.php

@@ -158,9 +158,9 @@ class Template extends Node {
 		}
 		
 		if (!$found) {
-			throw new \RuntimeException(
-				sprintf("Could not find template file \"%s\", looked in folders:\n%s",
-					$filename, implode("\n", $look_in))
+			throw new FormattedException(
+				"Could not find template file \"%s\", looked in folders:\n%s",
+				$filename, implode("\n", $look_in)
 			);
 		}
 		
@@ -455,7 +455,7 @@ class Template extends Node {
 				// <nested_exp>||<nested_exp>
 				try {
 					return self::evaluateExpression(substr($expression, 0, $split_at), $data, false);
-				} catch(\RuntimeException $e) {
+				} catch(\Exception $e) {
 					return self::evaluateExpression(substr($expression, $split_at + 2), $data, false);
 				}
 			}
@@ -505,7 +505,7 @@ class Template extends Node {
  * 
  * @package WebBasics
  */
-class ParseError extends \RuntimeException {
+class ParseError extends \Exception {
 	/**
 	 * Constructor.
 	 * 

+ 1 - 1
tests/test_template.php

@@ -92,7 +92,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
 	}
 	
 	/**
-	 * @expectedException RuntimeException
+	 * @expectedException webbasics\FormattedException
 	 */
 	function testNonExistingTemplate() {
 		$bar = new Template('bar');