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: #45606
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Kohei Ueno <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
  • Loading branch information
deokjinkim authored and targos committed Dec 12, 2022
1 parent 845f805 commit aabfdef
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 @@ -3186,7 +3186,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 @@ -3200,7 +3200,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 @@ -3231,7 +3231,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 @@ -3245,7 +3245,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 @@ -3276,7 +3276,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 @@ -3290,7 +3290,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 @@ -3321,7 +3321,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 @@ -3334,7 +3334,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 @@ -3365,7 +3365,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 @@ -3379,7 +3379,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 aabfdef

Please sign in to comment.