blob: eebfbafdfde58f282b91630b40da26fe9c148511 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
'use strict';
const common = require('../common');
const fs = require('fs');
const readline = require('readline');
const path = require('path');
async function processLineByLine_SymbolAsyncError(filename) {
const fileStream = fs.createReadStream(filename);
const rl = readline.createInterface({
input: fileStream,
crlfDelay: Infinity
});
// eslint-disable-next-line no-unused-vars
for await (const line of rl) {
/* check SymbolAsyncIterator `errorListener` */
}
}
const f = path.join(__dirname, 'file.txt');
// catch-able SymbolAsyncIterator `errorListener` error
processLineByLine_SymbolAsyncError(f).catch(common.expectsError({
code: 'ENOENT',
message: `ENOENT: no such file or directory, open '${f}'`
}));
async function processLineByLine_InterfaceErrorEvent(filename) {
const fileStream = fs.createReadStream(filename);
const rl = readline.createInterface({
input: fileStream,
crlfDelay: Infinity
});
rl.on('error', common.expectsError({
code: 'ENOENT',
message: `ENOENT: no such file or directory, open '${f}'`
}));
}
// check Interface 'error' event
processLineByLine_InterfaceErrorEvent(f);
|