diff options
| author | Kevin Brothaler <contact@digipom.com> | 2016-03-18 11:19:20 -0400 |
|---|---|---|
| committer | Kevin Brothaler <contact@digipom.com> | 2016-03-18 11:40:45 -0400 |
| commit | 8f99ad2a2a8a95b395de93d692f1b652721e94c8 (patch) | |
| tree | abc1b97e6e4702d3081e5568505441077ceb1500 | |
| parent | b12b4e4e3266644d519647afc2943cefa2026e07 (diff) | |
| download | rust-8f99ad2a2a8a95b395de93d692f1b652721e94c8.tar.gz rust-8f99ad2a2a8a95b395de93d692f1b652721e94c8.zip | |
Update of the book; Error handling, section on custom error types: we should also show the changes to the `cause` method.
| -rw-r--r-- | src/doc/book/error-handling.md | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/doc/book/error-handling.md b/src/doc/book/error-handling.md index 11086af10bd..12cb71973ab 100644 --- a/src/doc/book/error-handling.md +++ b/src/doc/book/error-handling.md @@ -2019,6 +2019,16 @@ impl Error for CliError { CliError::NotFound => "not found", } } + + fn cause(&self) -> Option<&error::Error> { + match *self { + CliError::Io(ref err) => Some(err), + CliError::Parse(ref err) => Some(err), + // Our custom error doesn't have an underlying cause, but we could + // modify it so that it does. + CliError::NotFound() => None, + } + } } ``` |
