Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: use console.error for error case in fs, https, net and process #45606

Merged
merged 1 commit into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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