Skip to content

Instantly share code, notes, and snippets.

@vibs2006
Last active June 14, 2023 12:17
Show Gist options
  • Save vibs2006/ae331e3b6947cd8e634cc9618c5853dd to your computer and use it in GitHub Desktop.
Save vibs2006/ae331e3b6947cd8e634cc9618c5853dd to your computer and use it in GitHub Desktop.
C# Small Utilities
  1. Recursive Inner Exception Looping for Logging Purpose.
try
{
}
catch (Exception Ex)
{
_logger.Error(Ex, "Error Occurred");
StringBuilder sb = new StringBuilder();
sb.AppendLine(Ex.Message);
sb.AppendLine(Ex.Source);
sb.AppendLine(Ex.StackTrace);
while (Ex.InnerException != null)
{
Ex = Ex.InnerException;
sb.AppendLine(Ex.Message);
sb.AppendLine(Ex.Source);
sb.AppendLine(Ex.StackTrace);
}
return Content(sb.ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment