Add error handling for less compiler

refs #4892
This commit is contained in:
Marius Hein 2013-10-16 15:48:12 +02:00
parent 6f26df60f3
commit c624921792
1 changed files with 11 additions and 2 deletions

View File

@ -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;