diff --git a/book/contents/advance/errors.md b/book/contents/advance/errors.md index 1fedd462..1a76d508 100644 --- a/book/contents/advance/errors.md +++ b/book/contents/advance/errors.md @@ -255,7 +255,7 @@ fn main() { ## 自定义错误类型 虽然标准库定义了大量的错误类型,但是一个严谨的项目,光使用这些错误类型往往是不够的,例如我们可能会为暴露给用户的错误定义相应的类型。 -为了帮助我们更好的定义错误,Rust 在标准库中提供了一些可复用的特征,例如 `std::error::Erro` 特征: +为了帮助我们更好的定义错误,Rust 在标准库中提供了一些可复用的特征,例如 `std::error::Error` 特征: ```rust use std::fmt::{Debug, Display}; @@ -347,7 +347,7 @@ fn produce_error() -> Result<(), AppError> { fn main() { match produce_error() { - Err(e) => eprintln!("{}", e), // 抱歉,未找到指定的页面! + Err(e) => eprintln!("{}", e), // Sorry, Can not find the Page! _ => println!("No error"), } @@ -599,7 +599,7 @@ enum MyError { } ``` -如上所示,只要简单谢谢注释,就可以实现错误处理了,惊不惊喜? +如上所示,只要简单写写注释,就可以实现错误处理了,惊不惊喜? #### error-chain [`error-chain`](https://github.com/rust-lang-deprecated/error-chain) 也是简单好用的库,可惜不再维护了,但是我觉得它依然可以在合适的地方大放光彩,值得大家去了解下。