From: kaldari Date: Thu, 12 Mar 2015 21:31:32 +0000 (-0700) Subject: Replacing generic Exception with Exception subclasses X-Git-Tag: 1.31.0-rc.0~12112^2 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=a2def8064dba635594b1d9b588862acc6e5524aa;p=lhc%2Fweb%2Fwiklou.git Replacing generic Exception with Exception subclasses Improves ability to debug. Change-Id: I21a51fc5b4f185a01ba4706bd5a853c2974057dd --- diff --git a/includes/TemplateParser.php b/includes/TemplateParser.php index 0dbf2c73ea..a22f2801d9 100644 --- a/includes/TemplateParser.php +++ b/includes/TemplateParser.php @@ -49,7 +49,7 @@ class TemplateParser { * Constructs the location of the the source Mustache template * @param string $templateName The name of the template * @return string - * @throws Exception Disallows upwards directory traversal via $templateName + * @throws UnexpectedValueException Disallows upwards directory traversal via $templateName */ public function getTemplateFilename( $templateName ) { // Prevent upwards directory traversal using same methods as Title::secureAndSplit @@ -65,7 +65,7 @@ class TemplateParser { substr( $templateName, -3 ) === '/..' ) ) { - throw new Exception( "Malformed \$templateName: $templateName" ); + throw new UnexpectedValueException( "Malformed \$templateName: $templateName" ); } return "{$this->templateDir}/{$templateName}.mustache"; @@ -75,7 +75,7 @@ class TemplateParser { * Returns a given template function if found, otherwise throws an exception. * @param string $templateName The name of the template (without file suffix) * @return Function - * @throws Exception + * @throws RuntimeException */ public function getTemplate( $templateName ) { // If a renderer has already been defined for this template, reuse it @@ -86,7 +86,7 @@ class TemplateParser { $filename = $this->getTemplateFilename( $templateName ); if ( !file_exists( $filename ) ) { - throw new Exception( "Could not locate template: {$filename}" ); + throw new RuntimeException( "Could not locate template: {$filename}" ); } // Read the template file @@ -143,14 +143,14 @@ class TemplateParser { * @param string $fileContents Mustache code * @param string $filename Name of the template * @return string PHP code (without '