954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

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.

try
{
    //some code
}

catch(Exception ex)
{
   //How to display this Exception as a string in MessageBox::Show(); ?
}
Lukezzz
Posting Whiz in Training
268 posts since Mar 2008
Reputation Points: 10
Solved Threads: 1
 

Found a solution:

String^ GetException= ex2->ToString();
MessageBox::Show(GetException);

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.

try
{
    //some code
}

catch(Exception ex)
{
   //How to display this Exception as a string in MessageBox::Show(); ?
}
Lukezzz
Posting Whiz in Training
268 posts since Mar 2008
Reputation Points: 10
Solved Threads: 1
 
try { ... throw("error") }
catch { const char *err)
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
 

try
{
int ....;
cout << "" << balances[k] << endl;
}
catch(string err)
{
cout << "" << err << edl;
}

kavitababar
Newbie Poster
1 post since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You