12
12
*/
13
13
class Oyejorge implements \Magento \Framework \Css \PreProcessor \AdapterInterface
14
14
{
15
+ /**
16
+ * @var \Psr\Log\LoggerInterface
17
+ */
18
+ protected $ logger ;
19
+
15
20
/**
16
21
* @var \Magento\Framework\App\State
17
22
*/
18
23
protected $ appState ;
19
24
20
25
/**
21
- * @param \Magento\Framework\App\State $appState
26
+ * @param \Psr\Log\LoggerInterface $logger
27
+ * @param State $appState
22
28
*/
23
- public function __construct (State $ appState )
24
- {
29
+ public function __construct (
30
+ \Psr \Log \LoggerInterface $ logger ,
31
+ State $ appState
32
+ ) {
33
+ $ this ->logger = $ logger ;
25
34
$ this ->appState = $ appState ;
26
35
}
27
36
@@ -32,8 +41,14 @@ public function __construct(State $appState)
32
41
public function process ($ sourceFilePath )
33
42
{
34
43
$ options = ['relativeUrls ' => false , 'compress ' => $ this ->appState ->getMode () !== State::MODE_DEVELOPER ];
35
- $ parser = new \Less_Parser ($ options );
36
- $ parser ->parseFile ($ sourceFilePath , '' );
37
- return $ parser ->getCss ();
44
+ try {
45
+ $ parser = new \Less_Parser ($ options );
46
+ $ parser ->parseFile ($ sourceFilePath , '' );
47
+ return $ parser ->getCss ();
48
+ } catch (\Exception $ e ) {
49
+ $ messagePrefix = 'CSS compilation from LESS ' ;
50
+ $ this ->logger ->critical ($ messagePrefix . $ e ->getMessage ());
51
+ return $ messagePrefix . $ e ->getMessage ();
52
+ }
38
53
}
39
54
}
0 commit comments