try-catch exception
-
Hi, my application is a win32 appln. I have added try-catch loop. But its showing the following error.Please help me to resolve this error. Code: try { fn(); } catch(CException exp) { exp->GetErrorMessage(lpszErr,sizeof(lpszErr),NULL); wsprintf(lpszLogMsg,"%s\\%s",lpszErr,"fn"); WriteLog(0,lpszLogMsg); return; } Error: error C2061: syntax error : identifier 'CException' error C2310: catch handlers must specify one type error C2227: left of '->GetErrorMessage' must point to class/struct/union error C2317: 'try' block starting on line '474' has no catch handlers
-
Hi, my application is a win32 appln. I have added try-catch loop. But its showing the following error.Please help me to resolve this error. Code: try { fn(); } catch(CException exp) { exp->GetErrorMessage(lpszErr,sizeof(lpszErr),NULL); wsprintf(lpszLogMsg,"%s\\%s",lpszErr,"fn"); WriteLog(0,lpszLogMsg); return; } Error: error C2061: syntax error : identifier 'CException' error C2310: catch handlers must specify one type error C2227: left of '->GetErrorMessage' must point to class/struct/union error C2317: 'try' block starting on line '474' has no catch handlers
-
Hi, my application is a win32 appln. I have added try-catch loop. But its showing the following error.Please help me to resolve this error. Code: try { fn(); } catch(CException exp) { exp->GetErrorMessage(lpszErr,sizeof(lpszErr),NULL); wsprintf(lpszLogMsg,"%s\\%s",lpszErr,"fn"); WriteLog(0,lpszLogMsg); return; } Error: error C2061: syntax error : identifier 'CException' error C2310: catch handlers must specify one type error C2227: left of '->GetErrorMessage' must point to class/struct/union error C2317: 'try' block starting on line '474' has no catch handlers
The exception type you are trying to catch has to be defined. The error simply reads: I don't know what
CException
is. You might be missing an#include
, definingCException
. There is no predefined exception class in C++ as in many other languages. In C++ you can throw whatever object you want; int, const char*, CMyComplexClass... Always try to catch exceptions by reference instead of by value. That will avoid a lot of unnecessary copying of data.catch(CException &exp)
-
try
{
fn();
}
catch(Exception *exp)
{
exp->GetErrorMessage(lpszErr,sizeof(lpszErr),NULL);
wsprintf(lpszLogMsg,"%s\\%s",lpszErr,"fn");
WriteLog(0,lpszLogMsg);
return;
}Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
-
now the errors has gone.Can you please tell me how to get the error message. ni CExeception we are having GetErrorMessage() fn. Similarly, what is the fn in exception class to get the error message?
-
The exception type you are trying to catch has to be defined. The error simply reads: I don't know what
CException
is. You might be missing an#include
, definingCException
. There is no predefined exception class in C++ as in many other languages. In C++ you can throw whatever object you want; int, const char*, CMyComplexClass... Always try to catch exceptions by reference instead of by value. That will avoid a lot of unnecessary copying of data.catch(CException &exp)