forked from HowProgrammingWorks/AsyncAwait
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7-errors.js
More file actions
23 lines (19 loc) · 531 Bytes
/
Copy path7-errors.js
File metadata and controls
23 lines (19 loc) · 531 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
const fs = require('node:fs');
const { readFile } = fs.promises;
(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);
}
})();