about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKevin Brothaler <contact@digipom.com>2016-03-18 11:19:20 -0400
committerKevin Brothaler <contact@digipom.com>2016-03-18 11:40:45 -0400
commit8f99ad2a2a8a95b395de93d692f1b652721e94c8 (patch)
treeabc1b97e6e4702d3081e5568505441077ceb1500
parentb12b4e4e3266644d519647afc2943cefa2026e07 (diff)
downloadrust-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.md10
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,
+        }
+    }
 }
 ```