I'm testing all the scenarios on reading files using new FileReader();
When the read is done, onload() should be triggered.
I have no idea how to trigger onerror() callback
Any idea?
var promise = Promise.create();
var fileReader = new FileReader();
fileReader.onload = function () {
};
fileReader.onerror = function(event) {
// I want to stay here ..........
// Who can tell me how to trigger this onerror callback?
debugger
};
fileReader.readAsText(inputFile);
return promise;
Try simply calling abort:
var promise = Promise.create();
var fileReader = new FileReader();
fileReader.onload = function () {
fileReader.abort()
};
fileReader.onerror = function(event) {
// I want to stay here ..........
// Who can tell me how to trigger this onerror callback?
debugger
};
fileReader.readAsText(inputFile);
return promise;
If that doesn't work you can try a permissions error with something like:
touch testfile
chmod 000 testfile
And open that file from your reader.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With