Throw clearer error if invalid type is passed to File.getContentsAsync()
This commit is contained in:
parent
f2440eb826
commit
56d9372146
1 changed files with 7 additions and 2 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue