Skip to content

Commit aabfdef

Browse files
deokjinkimtargos
authored andcommitted
doc: use console.error for error case in fs, https, net and process
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>
1 parent 845f805 commit aabfdef

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

doc/api/fs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -941,15 +941,15 @@ try {
941941
await copyFile('source.txt', 'destination.txt');
942942
console.log('source.txt was copied to destination.txt');
943943
} catch {
944-
console.log('The file could not be copied');
944+
console.error('The file could not be copied');
945945
}
946946

947947
// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
948948
try {
949949
await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
950950
console.log('source.txt was copied to destination.txt');
951951
} catch {
952-
console.log('The file could not be copied');
952+
console.error('The file could not be copied');
953953
}
954954
```
955955

doc/api/https.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let https;
2424
try {
2525
https = require('node:https');
2626
} catch (err) {
27-
console.log('https support is disabled!');
27+
console.error('https support is disabled!');
2828
}
2929
```
3030

@@ -42,7 +42,7 @@ let https;
4242
try {
4343
https = await import('node:https');
4444
} catch (err) {
45-
console.log('https support is disabled!');
45+
console.error('https support is disabled!');
4646
}
4747
```
4848

doc/api/net.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ after a certain amount of time:
409409
```js
410410
server.on('error', (e) => {
411411
if (e.code === 'EADDRINUSE') {
412-
console.log('Address in use, retrying...');
412+
console.error('Address in use, retrying...');
413413
setTimeout(() => {
414414
server.close();
415415
server.listen(PORT, HOST);

doc/api/process.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,7 +3186,7 @@ if (process.getegid && process.setegid) {
31863186
process.setegid(501);
31873187
console.log(`New gid: ${process.getegid()}`);
31883188
} catch (err) {
3189-
console.log(`Failed to set gid: ${err}`);
3189+
console.error(`Failed to set gid: ${err}`);
31903190
}
31913191
}
31923192
```
@@ -3200,7 +3200,7 @@ if (process.getegid && process.setegid) {
32003200
process.setegid(501);
32013201
console.log(`New gid: ${process.getegid()}`);
32023202
} catch (err) {
3203-
console.log(`Failed to set gid: ${err}`);
3203+
console.error(`Failed to set gid: ${err}`);
32043204
}
32053205
}
32063206
```
@@ -3231,7 +3231,7 @@ if (process.geteuid && process.seteuid) {
32313231
process.seteuid(501);
32323232
console.log(`New uid: ${process.geteuid()}`);
32333233
} catch (err) {
3234-
console.log(`Failed to set uid: ${err}`);
3234+
console.error(`Failed to set uid: ${err}`);
32353235
}
32363236
}
32373237
```
@@ -3245,7 +3245,7 @@ if (process.geteuid && process.seteuid) {
32453245
process.seteuid(501);
32463246
console.log(`New uid: ${process.geteuid()}`);
32473247
} catch (err) {
3248-
console.log(`Failed to set uid: ${err}`);
3248+
console.error(`Failed to set uid: ${err}`);
32493249
}
32503250
}
32513251
```
@@ -3276,7 +3276,7 @@ if (process.getgid && process.setgid) {
32763276
process.setgid(501);
32773277
console.log(`New gid: ${process.getgid()}`);
32783278
} catch (err) {
3279-
console.log(`Failed to set gid: ${err}`);
3279+
console.error(`Failed to set gid: ${err}`);
32803280
}
32813281
}
32823282
```
@@ -3290,7 +3290,7 @@ if (process.getgid && process.setgid) {
32903290
process.setgid(501);
32913291
console.log(`New gid: ${process.getgid()}`);
32923292
} catch (err) {
3293-
console.log(`Failed to set gid: ${err}`);
3293+
console.error(`Failed to set gid: ${err}`);
32943294
}
32953295
}
32963296
```
@@ -3321,7 +3321,7 @@ if (process.getgroups && process.setgroups) {
33213321
process.setgroups([501]);
33223322
console.log(process.getgroups()); // new groups
33233323
} catch (err) {
3324-
console.log(`Failed to set groups: ${err}`);
3324+
console.error(`Failed to set groups: ${err}`);
33253325
}
33263326
}
33273327
```
@@ -3334,7 +3334,7 @@ if (process.getgroups && process.setgroups) {
33343334
process.setgroups([501]);
33353335
console.log(process.getgroups()); // new groups
33363336
} catch (err) {
3337-
console.log(`Failed to set groups: ${err}`);
3337+
console.error(`Failed to set groups: ${err}`);
33383338
}
33393339
}
33403340
```
@@ -3365,7 +3365,7 @@ if (process.getuid && process.setuid) {
33653365
process.setuid(501);
33663366
console.log(`New uid: ${process.getuid()}`);
33673367
} catch (err) {
3368-
console.log(`Failed to set uid: ${err}`);
3368+
console.error(`Failed to set uid: ${err}`);
33693369
}
33703370
}
33713371
```
@@ -3379,7 +3379,7 @@ if (process.getuid && process.setuid) {
33793379
process.setuid(501);
33803380
console.log(`New uid: ${process.getuid()}`);
33813381
} catch (err) {
3382-
console.log(`Failed to set uid: ${err}`);
3382+
console.error(`Failed to set uid: ${err}`);
33833383
}
33843384
}
33853385
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy