diff --git a/library/Icinga/Web/LessCompiler.php b/library/Icinga/Web/LessCompiler.php index cbf486122..2c156ac1d 100644 --- a/library/Icinga/Web/LessCompiler.php +++ b/library/Icinga/Web/LessCompiler.php @@ -3,6 +3,7 @@ namespace Icinga\Web; +use Exception; use Icinga\Application\Logger; use Icinga\Util\LessParser; @@ -249,10 +250,14 @@ class LessCompiler $this->source .= file_get_contents($this->themeMode); } - return preg_replace( - '/(\.icinga-module\.module-[^\s]+) (#layout\.[^\s]+)/m', - '\2 \1', - $this->lessc->compile($this->source) - ); + try { + return preg_replace( + '/(\.icinga-module\.module-[^\s]+) (#layout\.[^\s]+)/m', + '\2 \1', + $this->lessc->compile($this->source) + ); + } catch (Exception $e) { + return sprintf("%s\n%s\n\n\n%s", $e->getMessage(), $e->getTraceAsString(), substr($this->source, $e->index - 250, 500)); + } } }