|
55 | 55 | //! and implementation boilerplate necessary for fulfilling a
|
56 | 56 | //! particular error-handling strategy. Most importantly it defines a
|
57 | 57 | //! custom error type (called `Error` by convention) and the `From`
|
58 |
| -//! conversions that let the `try!` macro and `?` operator work. |
| 58 | +//! conversions that let the `?` operator work. |
59 | 59 | //!
|
60 | 60 | //! This library differs in a few ways from previous error libs:
|
61 | 61 | //!
|
|
211 | 211 | //! strings and `ErrorKind` have `From` conversions to turn them into
|
212 | 212 | //! `Error`.
|
213 | 213 | //!
|
214 |
| -//! When the error is emitted inside a `try!` macro or behind the |
215 |
| -//! `?` operator, the explicit conversion isn't needed; `try!` will |
216 |
| -//! automatically convert `Err(ErrorKind)` to `Err(Error)`. So the |
217 |
| -//! below is equivalent to the previous: |
| 214 | +//! When the error is emitted behind the `?` operator, the explicit conversion |
| 215 | +//! isn't needed; `Err(ErrorKind)` will automatically be converted to `Err(Error)`. |
| 216 | +//! So the below is equivalent to the previous: |
218 | 217 | //!
|
219 | 218 | //! ```
|
220 | 219 | //! # #[macro_use] extern crate error_chain;
|
221 | 220 | //! # fn main() {}
|
222 | 221 | //! # error_chain! { errors { FooError } }
|
223 | 222 | //! fn foo() -> Result<()> {
|
224 |
| -//! Ok(try!(Err(ErrorKind::FooError))) |
| 223 | +//! Ok(Err(ErrorKind::FooError)?) |
225 | 224 | //! }
|
226 | 225 | //!
|
227 | 226 | //! fn bar() -> Result<()> {
|
228 |
| -//! Ok(try!(Err("bogus!"))) |
| 227 | +//! Ok(Err("bogus!")?) |
229 | 228 | //! }
|
230 | 229 | //! ```
|
231 | 230 | //!
|
|
437 | 436 | //! can still be included in the error chain. They are considered "foreign
|
438 | 437 | //! errors", and are declared using the `foreign_links` block of the
|
439 | 438 | //! `error_chain!` macro. `Error`s are automatically created from
|
440 |
| -//! foreign errors by the `try!` macro. |
| 439 | +//! foreign errors by the `?` operator. |
441 | 440 | //!
|
442 | 441 | //! Foreign links and regular links have one crucial difference:
|
443 | 442 | //! `From` conversions for regular links *do not introduce a new error
|
@@ -580,14 +579,14 @@ impl<'a, T> fmt::Display for Display<'a, T>
|
580 | 579 | where T: ChainedError
|
581 | 580 | {
|
582 | 581 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
583 |
| - try!(writeln!(fmt, "Error: {}", self.0)); |
| 582 | + writeln!(fmt, "Error: {}", self.0)?; |
584 | 583 |
|
585 | 584 | for e in self.0.iter().skip(1) {
|
586 |
| - try!(writeln!(fmt, "Caused by: {}", e)); |
| 585 | + writeln!(fmt, "Caused by: {}", e)?; |
587 | 586 | }
|
588 | 587 |
|
589 | 588 | if let Some(backtrace) = self.0.backtrace() {
|
590 |
| - try!(writeln!(fmt, "{:?}", backtrace)); |
| 589 | + writeln!(fmt, "{:?}", backtrace)?; |
591 | 590 | }
|
592 | 591 |
|
593 | 592 | Ok(())
|
|
0 commit comments