Move backtrace from one error to another inside From implementation #388
Replies: 2 comments 9 replies
-
If I understand you, then the answer is "no". If you know nothing about Even when you know that Even if the provider API were stable, it would return an
This may just be an oversight on our part. Perhaps adding appropriate
Incidentally, |
Beta Was this translation helpful? Give feedback.
-
@shepmaster , I have found a solution for my case!
Yes, it doesn't move backtrace, but at least this code produces an error with the same backtrace inside |
Beta Was this translation helpful? Give feedback.
-
Good day!
Snafu has a feature to delegate backtrace generation to source error:
But is there any way to delegate backtrace generation in other direction, from
Error
toanother::Error
in case whenanother::Error
does know absolutely nothing aboutError
?I have not found any way to do this,
Box<dyn ErrorCompat>
doesn't compile.This feature will be helpfull for me, because I want to have a generic code in a generic library with it's own errors and traits. And have a case-specific library that implements traits from the generic one.
Below is a code with an example of my idea.
mod_a::Error
knows nothing aboutmod_b::Error
, but it have a generic error kindInternal
for my case. And the only way to code to compile is to implementFrom<mod_b::Error> for mod_a::Error
.The problem is that inside the
from()
method I callbuild()
on error. And this is where backtrace will point to, not the original error place in my code.I want to know, is it possible to move backtrace from one error to another?
Beta Was this translation helpful? Give feedback.
All reactions