diff --git a/calc.js b/calc.js index 3265688..24b893c 100644 --- a/calc.js +++ b/calc.js @@ -268,6 +268,11 @@ function parseAndCalculate(line) { } } + // Pre-checking before the calculator throws unreadable errors. + if (!gen.species.get(attacker)) throw Error(`No species ${attacker}`); + if (!gen.species.get(defender)) throw Error(`No species ${attacker}`); + if (!gen.moves.get(move)) throw Error(`No move ${move}`); + return calculate( gen, new Pokemon(gen, attacker, attackerOpts),