Skip to content

Commit

Permalink
doc: use console.error for error case in fs, https, net and process
Browse files Browse the repository at this point in the history
console.error is more suitable than console.log for error case.

PR-URL: nodejs#45606
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
  • Loading branch information
deokjinkim authored and ErickWendel committed Nov 30, 2022
1 parent c43ec11 commit 4948a82
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -941,15 +941,15 @@ try {
await copyFile('source.txt', 'destination.txt');
console.log('source.txt was copied to destination.txt');
} catch {
console.log('The file could not be copied');
console.error('The file could not be copied');
}

// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
try {
await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
console.log('source.txt was copied to destination.txt');
} catch {
console.log('The file could not be copied');
console.error('The file could not be copied');
}
```
Expand Down
4 changes: 2 additions & 2 deletions doc/api/https.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let https;
try {
https = require('node:https');
} catch (err) {
console.log('https support is disabled!');
console.error('https support is disabled!');
}
```

Expand All @@ -42,7 +42,7 @@ let https;
try {
https = await import('node:https');
} catch (err) {
console.log('https support is disabled!');
console.error('https support is disabled!');
}
```

Expand Down
2 changes: 1 addition & 1 deletion doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ after a certain amount of time:
```js
server.on('error', (e) => {
if (e.code === 'EADDRINUSE') {
console.log('Address in use, retrying...');
console.error('Address in use, retrying...');
setTimeout(() => {
server.close();
server.listen(PORT, HOST);
Expand Down
20 changes: 10 additions & 10 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -3198,7 +3198,7 @@ if (process.getegid && process.setegid) {
process.setegid(501);
console.log(`New gid: ${process.getegid()}`);
} catch (err) {
console.log(`Failed to set gid: ${err}`);
console.error(`Failed to set gid: ${err}`);
}
}
```
Expand All @@ -3212,7 +3212,7 @@ if (process.getegid && process.setegid) {
process.setegid(501);
console.log(`New gid: ${process.getegid()}`);
} catch (err) {
console.log(`Failed to set gid: ${err}`);
console.error(`Failed to set gid: ${err}`);
}
}
```
Expand Down Expand Up @@ -3243,7 +3243,7 @@ if (process.geteuid && process.seteuid) {
process.seteuid(501);
console.log(`New uid: ${process.geteuid()}`);
} catch (err) {
console.log(`Failed to set uid: ${err}`);
console.error(`Failed to set uid: ${err}`);
}
}
```
Expand All @@ -3257,7 +3257,7 @@ if (process.geteuid && process.seteuid) {
process.seteuid(501);
console.log(`New uid: ${process.geteuid()}`);
} catch (err) {
console.log(`Failed to set uid: ${err}`);
console.error(`Failed to set uid: ${err}`);
}
}
```
Expand Down Expand Up @@ -3288,7 +3288,7 @@ if (process.getgid && process.setgid) {
process.setgid(501);
console.log(`New gid: ${process.getgid()}`);
} catch (err) {
console.log(`Failed to set gid: ${err}`);
console.error(`Failed to set gid: ${err}`);
}
}
```
Expand All @@ -3302,7 +3302,7 @@ if (process.getgid && process.setgid) {
process.setgid(501);
console.log(`New gid: ${process.getgid()}`);
} catch (err) {
console.log(`Failed to set gid: ${err}`);
console.error(`Failed to set gid: ${err}`);
}
}
```
Expand Down Expand Up @@ -3333,7 +3333,7 @@ if (process.getgroups && process.setgroups) {
process.setgroups([501]);
console.log(process.getgroups()); // new groups
} catch (err) {
console.log(`Failed to set groups: ${err}`);
console.error(`Failed to set groups: ${err}`);
}
}
```
Expand All @@ -3346,7 +3346,7 @@ if (process.getgroups && process.setgroups) {
process.setgroups([501]);
console.log(process.getgroups()); // new groups
} catch (err) {
console.log(`Failed to set groups: ${err}`);
console.error(`Failed to set groups: ${err}`);
}
}
```
Expand Down Expand Up @@ -3377,7 +3377,7 @@ if (process.getuid && process.setuid) {
process.setuid(501);
console.log(`New uid: ${process.getuid()}`);
} catch (err) {
console.log(`Failed to set uid: ${err}`);
console.error(`Failed to set uid: ${err}`);
}
}
```
Expand All @@ -3391,7 +3391,7 @@ if (process.getuid && process.setuid) {
process.setuid(501);
console.log(`New uid: ${process.getuid()}`);
} catch (err) {
console.log(`Failed to set uid: ${err}`);
console.error(`Failed to set uid: ${err}`);
}
}
```
Expand Down

0 comments on commit 4948a82

Please sign in to comment.