Example script from README doesn't work?
mjhm opened this issue · 0 comments
mjhm commented
This script below should result in an exception being caught by the FileNotFoundError
predicate. Right?
Instead I'm seeing
Unhandled rejection Error: ENOENT: no such file or directory, open 'blah.txt'
at Error (native)
#!/usr/bin/env node
var Promise = require('bluebird');
require('core-error-predicates').globalize();
var fs = Promise.promisifyAll(require('fs'));
fs.readFileAsync("blah.txt", "utf8").then(function(contents) {
console.log("file contents:", contents);
})
.catch(FileNotFoundError, function(e) {
console.log("file blah.txt does not exist");
})
.catch(FileAccessError, function(e) {
console.log("no permissions to access blah.txt");
});