Stream: project-error-handling

Topic: Get the cause of a std::Error using failure?


view this post on Zulip Joshua Nelson (Oct 27 2020 at 16:30):

Reposting https://discord.com/channels/273534239310479360/274215136414400513/770684800096665640:

I'm using failure (I can't switch for reasons, it's a large code base) and I'm also using tera, which uses std::error::Error, not failure::Fail. When I try to look at the causes of an error, it always stops at the outer-most error instead of showing the root cause:

Error: failed while loading tera templates in "templates"

Caused by:
    Failed to parse "/home/joshua/src/rust/docs.rs/templates/header/package_navigation.html"

Is there a way to get this to show the root cause without switching away from failure?
This is the error itself, so I know it exists, it's just not being shown: https://docs.rs/tera/1.5.0/src/tera/tera.rs.html#187-L188
and I'm calling iter_causes: https://docs.rs/failure/0.1.8/failure/struct.Error.html#method.iter_causes

view this post on Zulip Jane Lusby (Oct 27 2020 at 16:55):

I think there was a transition plan for failure

view this post on Zulip Jane Lusby (Oct 27 2020 at 16:55):

we could theoretically drive that if someone wanted to do the implementation

view this post on Zulip Jane Lusby (Oct 27 2020 at 16:55):

It was sketched out in the original fix the error trait RFC

view this post on Zulip Joshua Nelson (Oct 27 2020 at 16:55):

I'd be interested in that

view this post on Zulip Joshua Nelson (Oct 27 2020 at 16:55):

it's not feasible for us to switch from failure until thiserror has backtraces on stable

view this post on Zulip Jane Lusby (Oct 27 2020 at 16:58):

if you don't mind writing your own eyre handler then I can walk you through getting back traces on stable

view this post on Zulip Jane Lusby (Oct 27 2020 at 16:59):

Not sure which one would be easier honestly

view this post on Zulip Jane Lusby (Oct 27 2020 at 16:59):

if you have to switch off a failure to get it anyways then this might not actually be easier than making a breaking change in failure itself

view this post on Zulip Joshua Nelson (Oct 27 2020 at 17:12):

Ooh that would be really cool

view this post on Zulip Joshua Nelson (Oct 27 2020 at 17:13):

@Nemo157 did most of the work to switch docs.rs but got stuck on backtraces


Last updated: Jan 26 2022 at 14:20 UTC