benaadams / Ben.Demystifier

High performance understanding for stack traces (Make error logs more productive)
Apache License 2.0
2.76k stars 118 forks source link

Expose cleaned up Exception #98

Open btecu opened 4 years ago

btecu commented 4 years ago

Right now when an exception is .Demystify() it exposes a cleaned up stack trace. The issue is, I'm using Bugsnag (probably not the only library) that takes the exception and builds some internal structure (StackTraceLine - https://github.com/bugsnag/bugsnag-dotnet/blob/96360fb0f8d31f5fd6a8f3f17184bd626421820e/src/Bugsnag/Payload/Exception.cs#L85) before logging it. Therefore, the Demystifier has no effect.

Can we please get a Demystify() that cleans up the stack frames as well so that if the exception is used in another library it will not include the unnecessary stack frames?

lutz commented 3 years ago

I have the same problem so i will support this proposal

Update

After few checks it seems to be work mostly correct. If i find a logic behind when it works and when not, i will post it here.

mingmoe commented 7 months ago

Check my fork:https://github.com/mingmoe/Mingmoe.Demystifier?tab=readme-ov-file

You can use the formatted string like

string msg = exception.ToColoredStringDemystified();

And it won't change anything of the exception.

bruno-garcia commented 7 months ago

Worth noting Sentry by default includes demystified stack traces image

It actually also includes snippets of the code, through source link or if you upload sources