You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
I'm not sure if I'm using the .context and with_context things as expected, but I'm trying to build detailed context „chains“ (and print all the levels when logging). However, sometimes doing that requires to jumping through ugly loops like this:
fndo_something(xy:&str) -> Result<Whatever,Error>{let inner = || {first_part()?;second_part()?;third_part(xy)?;};Ok(inner().with_context(|_| format!("Failed to do something about {}", xy)?))}
So I wonder, now we have the attribute style procedural macros, if it would be possible to do this kind of thing using a decorator like this:
#[failure(with_context = "Failed to do something about {}", xy)]fndo_something(xy:&str) -> Result<Whatever,Error>{first_part()?;second_part()?;third_part(xy)?;}
And possibly make it work on try blocks too.
Anyway, this is a very much rough and unformed idea.
The text was updated successfully, but these errors were encountered:
This seems hard since xy might not be available at the time the error occurs (if it's something non-copy, it could have been moved). Formatting at the start of the function would avoid this but would be unfortunate.
I guess it would be acceptable if the macro-generated code simply failed to compile in the non-copy case. After all, such problem exists with manual contexting as well and the case of the parameter being a reference or a copy type is reasonably common to be of some help even with the limitation.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello
I'm not sure if I'm using the
.context
andwith_context
things as expected, but I'm trying to build detailed context „chains“ (and print all the levels when logging). However, sometimes doing that requires to jumping through ugly loops like this:So I wonder, now we have the attribute style procedural macros, if it would be possible to do this kind of thing using a decorator like this:
And possibly make it work on
try
blocks too.Anyway, this is a very much rough and unformed idea.
The text was updated successfully, but these errors were encountered: