Closed shepmaster closed 3 years ago
I found the RFC at https://github.com/rust-lang/rfcs/pull/2091. I think this is what I'm looking for. Yesterday, I ended up sprinkling code like this everywhere:
let typ = ident(&alias_name.to_camel_case()).context(IdentError {
file: file!(),
line: line!(),
})?;
It would be great if there was a variable like source
that captured the caller
automatically.
captured the
caller
automatically.
I have doubts about the true value of this. Why do you reuse an error type so frequently? Concretely speaking, why do you use IdentError
in so many places that the file / line location is required to be able to make sense of a resulting error? If each context selector is used once, its name is already a unique identifier to locate the exact location of the problem.
Thanks @shepmaster. I'd like to get to a point where each one is uniquely named, but it was easiest at first to wrap an error type generically. Well, until the error was thrown and I couldn't figure out the location.
Closed via #247
This will involve adding a feature flag for Rust 1.46, then adding
#[track_caller]
to the context selector methods likebuild
andfail
.