Jake Goulding
Jake Goulding
> The example uses just one error type. The curse of examples, I suppose: how to make them small enough to understand quickly but large enough to provide value. Pragmatically,...
#78 is relevant as it will reduce some of the annoyance of adding more layers. With the example above, if the *only* time we used `config::Error` was via `UploadFile`, we'd...
> Add a method parallel to `fail` to construct unwrapped error instances: SNAFU 0.6.6 introduced `.build()` on leaf error contexts, so this can be: ```rust example().map_err(|e| Selector { e }.build())?...
Alright, I moved the cheat sheet to the `Snafu` macro, more aggressively linked to the macro docs from the crate doc root, and renamed the `the_macro` section of the guide....
I'm not totally following your motivating example. 1. `GetPathMetadata` / `GetDirectoryMetadata` look like maybe they are supposed to be the same (a typo?) but they have different fields. 1. `PathDoesNotExist`...
I suppose one close analog you can do today is ```rust use snafu::{IntoError, Snafu}; use std::{fs, io, path::PathBuf}; #[derive(Debug, Snafu)] enum Error { #[snafu(display("Path `{}` does not exist", path.display()))] PathDoesNotExist...
> you can also create your own extension trait on top of `Result` to immediately gain the ergonomic benefit in your code today. Perhaps not! Attempting your example: ```rust fn...
Closing due to a lack of clarity on what is being requested.
I'm going to 👍 the general gist here. I definitely wrote: ```rust let mut f = File::open(fname).with_context(|_| fname.clone())?; ``` Since the concepts of "open" and "filename" are the context of...
> it `Display`s the error even if the error never needs to be displayed @Laaas could you expand on that? `with_context` is [never called unless an error has occurred](https://github.com/rust-lang-nursery/failure/blob/94158d21235f13635f0b0143c40db6b594fee723/src/result_ext.rs#L167-L176). I...