Skip to content

Commit 630b95e

Browse files
authored
Update article.md
A few syntactic and punctuation changes to 'The “try…catch” syntax' section.
1 parent b30915a commit 630b95e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ No matter how great we are at programming, sometimes our scripts have errors. Th
44

55
Usually, a script "dies" (immediately stops) in case of an error, printing it to console.
66

7-
But there's a syntax construct `try..catch` that allows to "catch" errors and, instead of dying, do something more reasonable.
7+
But there's a syntax construct `try..catch` that allows us to "catch" errors so the script can, instead of dying, do something more reasonable.
88

99
## The "try..catch" syntax
1010

@@ -26,13 +26,13 @@ It works like this:
2626

2727
1. First, the code in `try {...}` is executed.
2828
2. If there were no errors, then `catch(err)` is ignored: the execution reaches the end of `try` and goes on, skipping `catch`.
29-
3. If an error occurs, then `try` execution is stopped, and the control flows to the beginning of `catch(err)`. The `err` variable (can use any name for it) will contain an error object with details about what happened.
29+
3. If an error occurs, then the `try` execution is stopped, and control flows to the beginning of `catch(err)`. The `err` variable (can use any name for it) will contain an error object with details about what happened.
3030

3131
![](try-catch-flow.svg)
3232

33-
So, an error inside the `try {…}` block does not kill the script: we have a chance to handle it in `catch`.
33+
So, an error inside the `try {…}` block does not kill the script -- we have a chance to handle it in `catch`.
3434

35-
Let's see examples.
35+
Let's look at some examples.
3636

3737
- An errorless example: shows `alert` `(1)` and `(2)`:
3838

@@ -87,7 +87,7 @@ try {
8787
8888
The JavaScript engine first reads the code, and then runs it. The errors that occur on the reading phase are called "parse-time" errors and are unrecoverable (from inside that code). That's because the engine can't understand the code.
8989
90-
So, `try..catch` can only handle errors that occur in the valid code. Such errors are called "runtime errors" or, sometimes, "exceptions".
90+
So, `try..catch` can only handle errors that occur in valid code. Such errors are called "runtime errors" or, sometimes, "exceptions".
9191
````
9292
9393

0 commit comments

Comments
 (0)