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 <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 danielleadams committed Jan 4, 2023
1 parent b57fd4d commit 7f26977
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 @@ -937,15 +937,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 @@ -407,7 +407,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 @@ -3190,7 +3190,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 @@ -3204,7 +3204,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 @@ -3235,7 +3235,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 @@ -3249,7 +3249,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 @@ -3280,7 +3280,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 @@ -3294,7 +3294,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 @@ -3325,7 +3325,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 @@ -3338,7 +3338,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 @@ -3369,7 +3369,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 @@ -3383,7 +3383,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 7f26977

Please sign in to comment.