From 00a408dabf9f851e52079fc1c16dd3fc5d948c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Galeran?= Date: Thu, 23 Jun 2016 12:53:14 +0200 Subject: [PATCH] Throw error when a name table entry is not existing + Improve throw error message of Font.download() --- src/font.js | 2 +- src/tables/name.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/font.js b/src/font.js index 8eac4124..c5c8b4cb 100644 --- a/src/font.js +++ b/src/font.js @@ -320,7 +320,7 @@ Font.prototype.download = function() { }); }, function(err) { - throw err; + throw new Error(err.name + ': ' + err.message); }); } else { var fs = require('fs'); diff --git a/src/tables/name.js b/src/tables/name.js index 56ae73c2..76ae1770 100644 --- a/src/tables/name.js +++ b/src/tables/name.js @@ -744,6 +744,11 @@ function makeNameTable(names, ltag) { } nameID = parseInt(id); + + if (isNaN(nameID)) { + throw new Error('Name table entry "' + key + '" does not exist, see nameTableNames for complete list.'); + } + namesWithNumericKeys[nameID] = names[key]; nameIDs.push(nameID); }