Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Compat should override method source() #316

Open
pchampin opened this issue Jun 12, 2019 · 1 comment
Open

Compat should override method source() #316

pchampin opened this issue Jun 12, 2019 · 1 comment

Comments

@pchampin
Copy link

Compat should override method source() to something like return self.cause().compat().
That way, the chain of causes of the Fail would be visible from code expecting the standard Error trait.

@vorner
Copy link

vorner commented Sep 3, 2019

I've also noticed it „loses“ the sources when going through compat.

However, I think the problem is that it returns Option<&dyn Error>. That means, it can't create the Compat on stack and return it, it would have to contain it in itself, which it probably doesn't. It can't reference thin air :-(.

I'm still trying to think of a hacky way to work around this (somewhat in direction of making Compat #[repr(transparent)] and do some clever transmuting, but the dyns there seem to pose problems there; I'm not sure this would be worth it even if it worked).

Other option would be to create a Vec of some Compat-like structs that would wrap the &dyn Errors and return these and let them delegate. This would still be problematic because such thing would be effectively a self-referencing structure and it would make the top-level Compat a bit more expensive to create, but I'm confident this could be beaten long enough to actually make it work (also with unsafe, though). Again, I'm not sure if it's worth it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants