chainerror/searchindex.js

1 line
866 KiB
JavaScript
Raw Normal View History

Object.assign(window.search, {"doc_urls":["index.html#chainerror","index.html#example","index.html#features","tutorial1.html#simple-string-errors","tutorial2.html#simple-chained-string-errors","tutorial2.html#what-did-we-do-here","tutorial3.html#mapping-errors","tutorial4.html#saving-coding-chars","tutorial5.html#the-source-of-errors","tutorial6.html#downcast-the-errors","tutorial7.html#the-root-cause-of-all-errors","tutorial8.html#finding-an-error-cause","tutorial9.html#selective-error-handling","tutorial10.html#errorkind-to-the-rescue","tutorial11.html#debug-for-the-errorkind","tutorial12.html#deref-for-the-errorkind","tutorial13.html#writing-a-library","tutorial14.html#going-back-to-std","end.html#the-end"],"index":{"documentStore":{"docInfo":{"0":{"body":60,"breadcrumbs":1,"title":1},"1":{"body":174,"breadcrumbs":1,"title":1},"10":{"body":2142,"breadcrumbs":3,"title":3},"11":{"body":2109,"breadcrumbs":3,"title":3},"12":{"body":2125,"breadcrumbs":3,"title":3},"13":{"body":2179,"breadcrumbs":2,"title":2},"14":{"body":2183,"breadcrumbs":2,"title":2},"15":{"body":2163,"breadcrumbs":2,"title":2},"16":{"body":2180,"breadcrumbs":2,"title":2},"17":{"body":347,"breadcrumbs":3,"title":3},"18":{"body":18,"breadcrumbs":1,"title":1},"2":{"body":20,"breadcrumbs":1,"title":1},"3":{"body":106,"breadcrumbs":3,"title":3},"4":{"body":2080,"breadcrumbs":4,"title":4},"5":{"body":46,"breadcrumbs":1,"title":1},"6":{"body":2098,"breadcrumbs":2,"title":2},"7":{"body":2084,"breadcrumbs":3,"title":3},"8":{"body":2097,"breadcrumbs":2,"title":2},"9":{"body":2109,"breadcrumbs":2,"title":2}},"docs":{"0":{"body":"Build Status Crate Rust Documentation chainerror provides an error backtrace like failure without doing a real backtrace, so even after you strip your binaries, you still have the error backtrace. chainerror has no dependencies! chainerror uses .source() of std::error::Error along with line()! and file()! to provide a nice debug error backtrace. It encapsulates all types, which have Display + Debug and can store the error cause internally. Along with the ChainError<T> struct, chainerror comes with some useful helper macros to save a lot of typing. Debug information is worth it! Now continue reading the Tutorial","breadcrumbs":"chainerror","id":"0","title":"chainerror"},"1":{"body":"Output: $ cargo run -q --example example\nMain Error Report: func1 error calling func2 Error reported by Func2Error: func2 error: calling func3 The root cause was: std::io::Error: Kind( NotFound\n) Debug Error:\nexamples/example.rs:45: func1 error calling func2\nCaused by:\nexamples/example.rs:20: Func2Error(func2 error: calling func3)\nCaused by:\nexamples/example.rs:13: Error reading 'foo.txt'\nCaused by:\nKind(NotFound) use chainerror::*;\nuse std::error::Error;\nuse std::io;\nuse std::result::Result; fn do_some_io() -> Result<(), Box<Error + Send + Sync>> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(())\n} fn func3() -> Result<(), Box<Error + Send + Sync>> { let filename = \"foo.txt\"; do_some_io().map_err(mstrerr!(\"Error reading '{}'\", filename))?; Ok(())\n} derive_str_cherr!(Func2Error); fn func2() -> ChainResult<(), Func2Error> { func3().map_err(mstrerr!(Func2Error, \"func2 error: calling func3\"))?; Ok(())\n} enum Func1Error { Func2, IO(String),\n} impl ::std::fmt::Display for Func1Error { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { match self { Func1Error::Func2 => write!(f, \"func1 error calling func2\"), Func1Error::IO(filename) => write!(f, \"Error reading '{}'\", filename), } }\n} impl ::std::fmt::Debug for Func1Error { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { write!(f, \"{}\", self) }\n} fn func1() -> ChainResult<(), Func1Error> { func2().map_err(|e| cherr!(e, Func1Error::Func2))?; let filename = String::from(\"bar.txt\"); do_some_io().map_err(|e| cherr!(e, Func1Error::IO(filename)))?; Ok(())\n} fn main() { if let Err(e) = func1() { match e.kind() { Func1Error::Func2 => eprintln!(\"Main Error Report: func1 error calling func2\"), Func1Error::IO(filename) => { eprintln!(\"Main Error Rep