Skip to main content

Display Exception on Try Catchtry-catch clause

Up to now when ever, whenever I wanted to Show the Exceptionshow an exception thrown from my code I used:

 try  {   ///// Code that  may throws several typesthrow ofdifferent Exceptionsexceptions  }   catch (Exception ex)  {   MessageBox.Show(ex.ToString());  } 

I used the above code mainly for debugging reasons, in order to see the exact type of exception and the according reason the exception was thrown.

In a project I am creating now, I use several try-catchtry-catch clauses and I would like to display a pop up Messagepopup message in case of an Exception thatexception, to make it would be "Usermore "user friendly".

  By "User"user friendly", I mean a Messagemessage that would hide phrases like: "Null Reference Exception" Null Reference Exception or "Argument Out of Range Exception"Argument Out Of Range Exception that are currently displayed with the above code. However

However I want, still the messagewant to sosee relevant info with the type of Exceptionexception that created the message.

Is there a way to format the displayed output of thrown exceptions according to previous needs?

Display Exception on Try Catch clause

Up to now when ever I wanted to Show the Exception thrown from my code I used:

 try  {   /////Code that  may throws several types of Exceptions  }   catch (Exception ex)  {   MessageBox.Show(ex.ToString());  } 

I used the above code mainly for debugging reasons, in order to see the exact type of exception and the according reason the exception was thrown.

In a project I am creating now, I use several try-catch clauses and I would like to display a pop up Message in case of an Exception that it would be "User friendly".

  By "User friendly", I mean a Message that would hide phrases like: "Null Reference Exception" or "Argument Out of Range Exception" that are currently displayed with the above code. However I want, still the message to so relevant info with the type of Exception that created the message.

Is there a way to format the displayed output of thrown exceptions according to previous needs?

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 above code mainly for debugging reasons, in order to see the exact type of exception and the according reason the exception was thrown.

In a project I am creating now, I use several try-catch clauses and I would like to display a popup message in case of an exception, to make it more "user friendly". By "user friendly", I mean a message that would hide phrases like Null Reference Exception or Argument Out Of Range Exception that are currently displayed with the above code.

However I still want to see relevant info with the type of exception that created the message.

Is there a way to format the displayed output of thrown exceptions according to previous needs?

edited tags
Link
Darren
  • 71.2k
  • 24
  • 141
  • 146
Source Link
apomene
  • 14.4k
  • 10
  • 51
  • 76

Display Exception on Try Catch clause

Up to now when ever I wanted to Show the Exception thrown from my code I used:

 try { /////Code that may throws several types of Exceptions } catch (Exception ex) { MessageBox.Show(ex.ToString()); } 

I used the above code mainly for debugging reasons, in order to see the exact type of exception and the according reason the exception was thrown.

In a project I am creating now, I use several try-catch clauses and I would like to display a pop up Message in case of an Exception that it would be "User friendly".

By "User friendly", I mean a Message that would hide phrases like: "Null Reference Exception" or "Argument Out of Range Exception" that are currently displayed with the above code. However I want, still the message to so relevant info with the type of Exception that created the message.

Is there a way to format the displayed output of thrown exceptions according to previous needs?