-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path7-errors.js
More file actions
22 lines (19 loc) · 532 Bytes
/
Copy path7-errors.js
File metadata and controls
22 lines (19 loc) · 532 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';
const fs = require('node:fs');
const { readFile } = fs.promises;
const main = async () => {
try {
const file1 = await readFile('1-prototype.js');
const file2 = await readFile('2-sync').catch((err) => {
console.log('Promise...catch');
console.error(err);
return readFile('2-sync.js');
});
const file3 = await readFile('3-async');
console.dir([file1.length, file2.length, file3.length]);
} catch (err) {
console.log('try...catch');
console.error(err);
}
};
main();