- Recursive Inner Exception Looping for Logging Purpose.
Last active
June 14, 2023 12:17
-
-
Save vibs2006/ae331e3b6947cd8e634cc9618c5853dd to your computer and use it in GitHub Desktop.
C# Small Utilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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