From dd2564e64cf609ca80cd551bd035e1d02b2825b3 Mon Sep 17 00:00:00 2001 From: Joel Burget Date: Mon, 3 Nov 2014 14:56:46 -0800 Subject: [PATCH] Stop silencing useful information. The thrown errors didn't hold any useful information and made debugging impossible. Before: Error: Could not parse jison grammar After: Error: Parse error on line 86: ... ;expatom = atom '^' nat --------------------^ Expecting ':', got 'ID' --- lib/cli.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 4bd502528..1d14faabc 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -160,21 +160,13 @@ cli.processGrammars = function processGrammars(file, lexFile, jsonMode) { var ebnfParser = require('ebnf-parser'); var cjson = require('cjson'); var grammar; - try { - if (jsonMode) { - grammar = cjson.parse(file); - } else { - grammar = ebnfParser.parse(file); - } - } catch (e) { - throw new Error('Could not parse jison grammar'); + if (jsonMode) { + grammar = cjson.parse(file); + } else { + grammar = ebnfParser.parse(file); } - try { - if (lexFile) { - grammar.lex = require('lex-parser').parse(lexFile); - } - } catch (e) { - throw new Error('Could not parse lex grammar'); + if (lexFile) { + grammar.lex = require('lex-parser').parse(lexFile); } return grammar; };