From c624921792bfe1333bd422551a0d6679bc8291ec Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 16 Oct 2013 15:48:12 +0200 Subject: [PATCH] Add error handling for less compiler refs #4892 --- library/Icinga/Web/LessCompiler.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/LessCompiler.php b/library/Icinga/Web/LessCompiler.php index a0eef5e99..6aad7e9f1 100644 --- a/library/Icinga/Web/LessCompiler.php +++ b/library/Icinga/Web/LessCompiler.php @@ -28,11 +28,12 @@ namespace Icinga\Web; -use \Zend_Controller_Front; +use \Exception; use \RecursiveDirectoryIterator; use \RecursiveIteratorIterator; use \RegexIterator; use \RecursiveRegexIterator; +use \Zend_Controller_Front; /** * Less compiler prints files or directories to stdout @@ -93,7 +94,15 @@ class LessCompiler if ($ext === 'css') { readfile($file); } elseif ($ext === 'less') { - echo $this->lessc->compileFile($file); + try { + echo $this->lessc->compileFile($file); + } catch (Exception $e) { + echo '/* ' . PHP_EOL . ' ===' . PHP_EOL; + echo ' Error in file ' . $file . PHP_EOL; + echo ' ' . $e->getMessage() . PHP_EOL . PHP_EOL; + echo ' ' . 'This file was dropped cause of errors.' . PHP_EOL; + echo ' ===' . PHP_EOL . '*/' . PHP_EOL; + } } echo PHP_EOL;