5 ms·
baz(foo).expect(format!("Cannot do baz, foo={}", foo)).bar().expect("Cannot do bar");
by michaelfairley 10y ago
baz(foo).expect(format!("Cannot do baz, foo={}", foo)).bar().expect("Cannot do bar");
- lisivka 10y agoWhere you found this expect() function and how it will receive error, generated by baz? I read Rust documentation about error handling multiple times, but newer saw adequate error handling. The best solution I know is error-chain library: use errors::ChainErr; try!(do_something().chain_err(|| "Something went wrong"));
- steveklabnik 10y agohttps://doc.rust-lang.org/stable/std/result/enum.Result.html#method.expect https://doc.rust-lang.org/stable/std/result/enum.Result.html...
- lisivka 10y agoPanic will stop program at place of error, while I want nicely stacked error message list: [reports.rs:25] ERROR: Cannot write report "Foo" to file "foo.xml". [templates.rs:125] ERROR: Cannot process template "header". Check is template file exists and readable. [fileio.rs:45] ERROR: Cannot open file "/usr/share/foo/templates/header.tmpl": unable to enter directory "/usr/share/foo". Check directory permissions. Instead of writing report cannot open file done It saves lot of time(money) in production.