Throw clearer error if invalid type is passed to File.getContentsAsync()

This commit is contained in:
Dan Stillman 2017-01-13 06:51:03 -05:00
parent f2440eb826
commit 56d9372146

View file

@ -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"