Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adding inner exception message to SelfLog #415

CarlJohan79 started this conversation in Ideas
Discussion options

Hi, it would be super userful if the the exception message of an inner exception could be added to the self log in the batch writing.

I had a scenario where it took me quite a while to figure out that I was really dealing with a binding problem with System.Runtime.InteropServices.RuntimeInformation rather than an error in the SQL-handling which the SelfLog displayed from the top level exception message.

You must be logged in to vote

Replies: 3 comments 2 replies

Comment options

Hi @CarlJohan79!

Thanks for bringing this up. Sounds like a good idea. There are only a few spots (four if i counted correctly) in the code where exceptions are logged using SelfLog. A general helper method for this checking if it's an aggregate/nested exception to log more details in this case would be a good improvement.

Can you provide a small sample program to help us testing such an implementation?

Regards,
Christian

You must be logged in to vote
1 reply
Comment options

Cool, could you perhaps implement something like this:

public static class ExceptionExtensions { public static string ToMessageAndCompleteStacktrace(this Exception exception) { Exception e = exception; StringBuilder s = new StringBuilder(); while (e != null) { s.AppendLine("Exception type: " + e.GetType().FullName); s.AppendLine("Message : " + e.Message); s.AppendLine(); e = e.InnerException; } return s.ToString(); } }

And then use it like this:

SelfLog.WriteLine(ex.ToMessageAndCompleteStacktrace());

Above copied from this thread: https://stackoverflow.com/questions/18489387/what-is-the-best-practice-for-capturing-all-inner-exception-details

Comment options

Looks good. Can you send a PR. I'll be happy to review it.

You must be logged in to vote
0 replies
Comment options

We have now merged a PR which fixes this issue. Please try it out with the latest dev version on nuget.org.

You must be logged in to vote
1 reply
Comment options

Cool, thanx, I will try it out as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /