Skip to content

Commit ead158a

Browse files
authored
Update article.md
Grammar suggestions
1 parent 072fa7d commit ead158a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

1-js/10-error-handling/1-try-catch/article.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ You can find more detailed information about JSON in the <info:json> chapter.
201201
202202
**If `json` is malformed, `JSON.parse` generates an error, so the script "dies".**
203203
204-
Should we be satisfied with that? Of course, not!
204+
Should we be satisfied with that? Of course not!
205205
206206
This way, if something's wrong with the data, the visitor will never know that (unless they open the developer console). And people really don't like when something "just dies" without any error message.
207207
@@ -334,9 +334,9 @@ Now `catch` became a single place for all error handling: both for `JSON.parse`
334334
335335
## Rethrowing
336336
337-
In the example above we use `try..catch` to handle incorrect data. But is it possible that *another unexpected error* occurs within the `try {...}` block? Like a programming error (variable is not defined) or something else, not just that "incorrect data" thing.
337+
In the example above we use `try..catch` to handle incorrect data. But is it possible that *another unexpected error* occurs within the `try {...}` block? Like a programming error (variable is not defined) or something else, not just this "incorrect data" thing.
338338
339-
Like this:
339+
For example:
340340
341341
```js run
342342
let json = '{ "age": 30 }'; // incomplete data
@@ -374,8 +374,8 @@ The rule is simple:
374374
The "rethrowing" technique can be explained in more detail as:
375375
376376
1. Catch gets all errors.
377-
2. In `catch(err) {...}` block we analyze the error object `err`.
378-
2. If we don't know how to handle it, then we do `throw err`.
377+
2. In the `catch(err) {...}` block we analyze the error object `err`.
378+
2. If we don't know how to handle it, we do `throw err`.
379379
380380
In the code below, we use rethrowing so that `catch` only handles `SyntaxError`:
381381
@@ -582,11 +582,11 @@ In the code above, an error inside `try` always falls out, because there's no `c
582582
The information from this section is not a part of the core JavaScript.
583583
```
584584
585-
Let's imagine we've got a fatal error outside of `try..catch`, and the script died. Like a programming error or something else terrible.
585+
Let's imagine we've got a fatal error outside of `try..catch`, and the script died. Like a programming error or some other terrible thing.
586586
587-
Is there a way to react on such occurrences? We may want to log the error, show something to the user (normally they don't see error messages) etc.
587+
Is there a way to react on such occurrences? We may want to log the error, show something to the user (normally they don't see error messages), etc.
588588
589-
There is none in the specification, but environments usually provide it, because it's really useful. For instance, Node.js has [`process.on("uncaughtException")`](https://nodejs.org/api/process.html#process_event_uncaughtexception) for that. And in the browser we can assign a function to special [window.onerror](mdn:api/GlobalEventHandlers/onerror) property, that will run in case of an uncaught error.
589+
There is none in the specification, but environments usually provide it, because it's really useful. For instance, Node.js has [`process.on("uncaughtException")`](https://nodejs.org/api/process.html#process_event_uncaughtexception) for that. And in the browser we can assign a function to the special [window.onerror](mdn:api/GlobalEventHandlers/onerror) property, that will run in case of an uncaught error.
590590
591591
The syntax:
592592

0 commit comments

Comments
 (0)