Created
February 2, 2024 17:31
-
-
Save joe-oli/62ef7bc54ef04ce4d8e6ac8e8c2f77ef to your computer and use it in GitHub Desktop.
Extract All exception messages
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
catch (Exception ex) | |
{ | |
tbOutput.Text = GetExceptionMessages(ex); | |
} | |
... | |
private string GetExceptionMessages(Exception ex) | |
{ | |
var message = ex.Message; | |
if (ex.InnerException != null) | |
{ | |
message += Environment.NewLine + "Inner Exception: " + GetExceptionMessages(ex.InnerException); | |
} | |
return message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment