Skip to content

Conversation

@kspearrin
Copy link

The ToString function of an exception already handles what you are trying to achieve with FormatStack, including inner exceptions.

ToString returns a representation of the current exception that is intended to be understood by humans. Where the exception contains culture-sensitive data, the string representation returned by ToString is required to take into account the current system culture. Although there are no exact requirements for the format of the returned string, it should attempt to reflect the value of the object as perceived by the user.

The default implementation of ToString obtains the name of the class that threw the current exception, the message, the result of calling ToString on the inner exception, and the result of calling Environment.StackTrace. If any of these members is null, its value is not included in the returned string.

If there is no error message or if it is an empty string (""), then no error message is returned. The name of the inner exception and the stack trace are returned only if they are not null.

ref http://msdn.microsoft.com/en-us/library/system.exception.tostring.aspx

Sometimes custom exceptions may override ToString() to include important information. In this case, that information is lost when translated to Loggr if FormatStack is used.

I also fixed a unnecessary null check on traceObject.

@kspearrin
Copy link
Author

Not sure if you want to keep the new line replacement with <br />. If so, I can add that back. I would recommend just wrapping it in <pre> though for even better formatting. I am unaware of how that affects the UI on the Loggr website, so I will leave that up to you. Let me know if you would like any changes.

@kspearrin
Copy link
Author

The <pre> formatting seems to work pretty well.

@kspearrin
Copy link
Author

Any plans to merge this for an update? I've been using a custom build for quite a while now in a production environment without an issue.

@ghost
Copy link

ghost commented May 6, 2016

Bump. Can we get this integrated and an update pushed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant