Page 145 - Nodejs 교과서 개정2판
P. 145
...
// 계속 반복
ী۞ח ߊࢤೞ݅ try catch۽ ਸ ࣻ Ҋ setIntervalب ݥ୶ӝ $USM $ ө ҅ࣘ प೯ؾפ
ۧѱ ী۞о ߊࢤೡ Ѫ э ࠗ࠙ਸ ܻ try DBUDI۽ хऱݶ ؾפ
ߣীח ֢٘ ীࢲ ইח ী۞ܳ ঌইࠁѷणפ
error2.js
const fs = require('fs');
setInterval(() => {
fs.unlink('./abcdefg.js', (err) => {
if (err) {
console.error(err);
}
});
}, 1000);
fs.unlink۽ ઓೞ ঋח ੌਸ Ҋ णפ ী۞о ߊࢤೞ݅ ೯ ֢٘ ղ ݽٕ ী۞ח प೯
ੋ ۽ࣁझܳ ݥ୶ ঋणפ ী۞ ۽Ӓܳ ӝ۾೧فҊ աী ਗੋਸ ই ࣻೞݶ ؾפ
ઁীࢲח ী۞о ߊࢤ೮ਸ ٸ ী۞ܳ throw೮णפ Ӓؘ۠ throwܳ ೞݶ ֢٘ ۽ࣁझо ݥߡ݀
פ ٮۄࢲ throwܳ ೞח ҃ীח ߈٘द try catchޙਵ۽ throwೠ ী۞ܳ ইঠ פ
콘솔
$ node error2
[Error: ENOENT: no such file or directory, unlink 'C:\Users\zerocho\abcdefg.js'] {
errno: -4058,
code: 'ENOENT',
syscall: 'unlink',
path: 'C:\\Users\\zerocho\\abcdefg.js'
}
[Error: ENOENT: no such file or directory, unlink 'C:\Users\zerocho\abcdefg.js'] {
errno: -4058,
code: 'ENOENT',
syscall: 'unlink',
path: 'C:\\Users\\zerocho\\abcdefg.js'
}
// 계속 반복