Answer by nassimlouchani for Display Exception on try-catch clause
try this code : try { // Code that may throw different exceptions } catch (Exception exp) { MessageBox.Show(exp.Message()); }
View ArticleAnswer by Darren for Display Exception on try-catch clause
You can use .Message, however I wouldn't recommend just catching Exception directly. Try catching multiple exceptions or explicitly state the exception and tailor the error message to the Exception...
View ArticleAnswer by Freelancer for Display Exception on try-catch clause
try { /////Code that may throws several types of Exceptions } catch (Exception ex) { MessageBox.Show(ex.Message); } Use above code. Can also show custom error message as: try { /////Code that may...
View ArticleAnswer by Arshad for Display Exception on try-catch clause
You can use Exception.Message property to get a message that describes the current exception. catch (Exception ex) { MessageBox.Show(ex.Messagge()); }
View ArticleAnswer by User 12345678 for Display Exception on try-catch clause
Exception.Message provides a more (but not entirely) user-friendly message than Exception.ToString(). Consider this contrived example: try { throw new InvalidOperationException(); }...
View ArticleDisplay Exception on try-catch clause
Up to now, whenever I wanted to show an exception thrown from my code I used: try { // Code that may throw different exceptions } catch (Exception ex) { MessageBox.Show(ex.ToString()); } I used the...
View ArticleAnswer by mekanaydemir for Display Exception on try-catch clause
The trick is using the Message method of the exception:catch (Exception ex){ MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);}
View Article
More Pages to Explore .....