Skip to content

Commit 3fbd8ea

Browse files
author
Eduardo Bar
committed
docs: fix incorrect example in Don't ignore rejected promises section
The previous Bad example called getdata() (lowercase 'd') inconsistently, and both Bad and Good examples looked structurally similar, making it unclear what the actual anti-pattern was. Changes: - Fix inconsistent casing: getdata() -> getData() in both examples - Add an inline comment in the Bad example to explain why console.log() alone is insufficient — it silently swallows the error without any visible action or user notification - Update comment in Good example from 'more noisy' to 'more visible' which is clearer and less pejorative This makes the distinction between the two examples obvious: the Bad example shows error handling that silently swallows details, while the Good example shows meaningful error handling strategies. Closes ryanmcdermott#718
1 parent 5311f64 commit 3fbd8ea

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,24 +2050,24 @@ from `try/catch`.
20502050
**Bad:**
20512051

20522052
```javascript
2053-
getdata()
2053+
getData()
20542054
.then(data => {
20552055
functionThatMightThrow(data);
20562056
})
20572057
.catch(error => {
2058-
console.log(error);
2058+
console.log(error); // Just logging is not enough — the error is silently swallowed
20592059
});
20602060
```
20612061

20622062
**Good:**
20632063

20642064
```javascript
2065-
getdata()
2065+
getData()
20662066
.then(data => {
20672067
functionThatMightThrow(data);
20682068
})
20692069
.catch(error => {
2070-
// One option (more noisy than console.log):
2070+
// One option (more visible than console.log):
20712071
console.error(error);
20722072
// Another option:
20732073
notifyUserOfError(error);

0 commit comments

Comments
 (0)