doc: add error check to fs example
Previously, the err passed to the callback of fs.open() was not checked. PR-URL: https://github.com/nodejs/node/pull/18681 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
parent
4a1a4bfc7e
commit
540cbf84af
@ -1397,6 +1397,7 @@ fs.open('myfile', 'wx', (err, fd) => {
|
||||
fs.exists('myfile', (exists) => {
|
||||
if (exists) {
|
||||
fs.open('myfile', 'r', (err, fd) => {
|
||||
if (err) throw err;
|
||||
readMyData(fd);
|
||||
});
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user