Get the Exception Error as string in try{} catch{}

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Mar 2008
Posts: 173
Reputation: Lukezzz is an unknown quantity at this point 
Solved Threads: 1
Lukezzz Lukezzz is offline Offline
Junior Poster

Get the Exception Error as string in try{} catch{}

 
0
  #1
Aug 2nd, 2009
How is it possible to get the Exception Error as a string in the catch event ?
The thing is that I get an exception and now want to know what the problem is and what the exception is saying.


  1. try
  2. {
  3. //some code
  4. }
  5.  
  6. catch(Exception ex)
  7. {
  8. //How to display this Exception as a string in MessageBox::Show(); ?
  9. }
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 173
Reputation: Lukezzz is an unknown quantity at this point 
Solved Threads: 1
Lukezzz Lukezzz is offline Offline
Junior Poster

Re: Get the Exception Error as string in try{} catch{}

 
0
  #2
Aug 2nd, 2009
Found a solution:
  1. String^ GetException= ex2->ToString();
  2. MessageBox::Show(GetException);

Originally Posted by Lukezzz View Post
How is it possible to get the Exception Error as a string in the catch event ?
The thing is that I get an exception and now want to know what the problem is and what the exception is saying.


  1. try
  2. {
  3. //some code
  4. }
  5.  
  6. catch(Exception ex)
  7. {
  8. //How to display this Exception as a string in MessageBox::Show(); ?
  9. }
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,457
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 189
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Nearly a Posting Virtuoso

Re: Get the Exception Error as string in try{} catch{}

 
0
  #3
Aug 2nd, 2009
  1. try { ... throw("error") }
  2. catch { const char *err)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 386 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC