From 56d937214611642f9ff176ea99b9c925ea2386ea Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 13 Jan 2017 06:51:03 -0500 Subject: [PATCH] Throw clearer error if invalid type is passed to File.getContentsAsync() --- chrome/content/zotero/xpcom/file.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index d03885d1d1..2e54259ff3 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -273,8 +273,13 @@ Zotero.File = new function(){ if (source instanceof Components.interfaces.nsIFile) { source = source.path; } - else if (source.startsWith('file:')) { - source = OS.Path.fromFileURI(source); + else if (typeof source == 'string') { + if (source.startsWith('file:')) { + source = OS.Path.fromFileURI(source); + } + } + else { + throw new Error(`Unsupported type '${typeof source}' for source`); } var options = { encoding: charset ? charset : "utf-8"