Skip to content

Commit 162280b

Browse files
committed
minor fixes
1 parent fd81db7 commit 162280b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

1-js/10-error-handling/2-custom-errors/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ Often the answer is "No": we'd like to be "one level above all that". We just wa
244244
The technique that we describe here is called "wrapping exceptions".
245245
246246
1. We'll make a new class `ReadError` to represent a generic "data reading" error.
247-
2. The function `readUser` will catch data reading errors that occur inside it, such as `ValidationError` and `SyntaxError`, and generate `ReadError` instead.
247+
2. The function `readUser` will catch data reading errors that occur inside it, such as `ValidationError` and `SyntaxError`, and generate a `ReadError` instead.
248248
3. The `ReadError` object will keep the reference to the original error in its `cause` property.
249249
250-
Then the code that calls `readUser` will only have to check for `ReadError`, not for every kind of data reading errors.
250+
Then the code that calls `readUser` will only have to check for `ReadError`, not for every kind of data reading errors. And if it needs more details of an error, it can check its `cause` property.
251251
252252
Here's the code that defines `ReadError` and demonstrates its use in `readUser` and `try..catch`:
253253

0 commit comments

Comments
 (0)