Skip to content

Fix minor typo #1249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 1-js/10-error-handling/2-custom-errors/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ try {
2. 函数`readUser` 将捕获内部发生的数据读取 error,例如 `ValidationError` 和 `SyntaxError`,并生成一个 `ReadError` 来进行替代。
3. 对象 `ReadError` 会把对原始 error 的引用保存在其 `cause` 属性中。

之后,调用 `readUser` 的代码只需要检查 `ReadError`,而不必检查每种数据读取 error。并且,如果需要更多 error 细节,那么可以检查 `readUser` 的 `cause` 属性。
之后,调用 `readUser` 的代码只需要检查 `ReadError`,而不必检查每种数据读取 error。并且,如果需要更多 error 细节,那么可以检查 `ReadError` 对象的 `cause` 属性。

下面的代码定义了 `ReadError`,并在 `readUser` 和 `try..catch` 中演示了其用法:

Expand Down