Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using the following syntax to catch exceptions using Visual C++ 1.0:

TRY
{
   //Some code
} 
CATCH(CException, e)
{                                   
  //Get info about error here?  Members of variable e?		
}
END_CATCH


I'd like to get more information about the exception when it is caught. Can I do that? If so, then how, please?


Regards,
Mike
Posted
Comments
Aravindba 6-Mar-14 22:39pm    
hi u need to what error in catch block ? just use e ,form e u can get what error in ur codings
mla154 7-Mar-14 7:55am    
Can you explain this further? How do I use 'e' to get the error?

1 solution

You have as much information as the object c can carry, no more, not less.

The resolution is on the throwing side. You may need to throw you own objects of your own exception types, so make sure they are informative enough. Often, such custom exceptions add just information on the environment. For example, you catch the exception related to integer division by zero. You can catch this exception and re-throw it, but not of the same type. You can have your own exception type designed to explain the circumstances, why that division happened, in what semantic operation, and throw that exception, instead of original "low-level" exception. This is one of the purposes of structural exception handling. Another, most important one is isolation of "regular" code from exceptional. Practically, you should not handle exception too locally.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900