Open sertal70 opened 7 years ago
any chances having someone looking at this?
Any ideas? have the same issue..
This is misleading and should be fixed, or at least clarified in the documentation. Thanks.
Since nobody seems to care about this issue, I've created this (dirty) wrapper...
fileExists(path, file) {
return new Promise((resolve, reject) => {
this.file.checkFile(path, file)
.then(() => resolve(true))
.catch(err => err.message === 'NOT_FOUND_ERR' ? resolve(false) : reject(err));
});
}
It returns a Promise
A call to File.checkFile() on a non-existent file results in a callback error with code NOT_FOUND_ERR. The function specification of checkFile() says:
Even if it is not further clarified in the specification, is almost intuitive expecting that it should return a Promise "false" if the file doesn't exist, instead of a reject with the NOT_FOUND_ERR code.
IMHO the function should rejects on error conditions only, for example on a non-existent path, etc. The non-existence of the file being checked is not an error but one of the possibles results of the function.
Thanks!