Quantcast
Channel: Display Exception on try-catch clause - Stack Overflow
Browsing all 7 articles
Browse latest View live

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 Article



Answer 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 Article

Answer 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 Article

Answer 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 Article

Answer 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 Article


Display 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 Article

Answer 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
Browsing all 7 articles
Browse latest View live




Latest Images