From 95a24cd29bcffa6885dc142b2fe8aea240691acb Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 30 Jan 2018 18:52:38 +0300 Subject: [PATCH] catch fatal parsing errors --- js/moz-parser.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/moz-parser.js b/js/moz-parser.js index 6a18ae62..f97de26e 100644 --- a/js/moz-parser.js +++ b/js/moz-parser.js @@ -80,9 +80,13 @@ function parseMozFormat({code, styleId}) { errors.push(`${e.line}:${e.col} ${e.message.replace(/ at line \d.+$/, '')}`); }); - parser.parse(mozStyle, { - reuseCache: !parseMozFormat.styleId || styleId === parseMozFormat.styleId, - }); + try { + parser.parse(mozStyle, { + reuseCache: !parseMozFormat.styleId || styleId === parseMozFormat.styleId, + }); + } catch (e) { + errors.push(e.message); + } parseMozFormat.styleId = styleId; return {sections, errors};