miette icon indicating copy to clipboard operation
miette copied to clipboard

IntoDiagnostic hides original error from downcasting

Open TheNeikos opened this issue 2 years ago • 1 comments

Currently IntoDiagnostic wraps the Error that it is called on with a DiagnosticError.

https://github.com/zkat/miette/blob/e6f5cacfa65cfe26255a5686ceb610b4a211931b/src/eyreish/into_diagnostic.rs#L22-L26

This means that any further inspection using is or downcast{,_ref,_mut} will fail to reach the inner type and only DiagnosticError can be reached. Since it is an implementation detail, I think it should be transparent to the user.

Maybe the downcast* methods could additionally safeguard against DiagnosticError and reach into it when encountering it?

TheNeikos avatar Apr 20 '22 08:04 TheNeikos

Being able to downcast back to the original error sounds super handy! I don't know if I can do this any time soon, but I'll happily take a patch to add this if anyone's willing!

zkat avatar Apr 20 '22 16:04 zkat