문제

In my application I got an exception message. This occurs when I throw false when an if() condition fails. The error message I got is as below

Unhandled exception at 0x74fe812f in MyApp.exe: Microsoft C++ exception: bool at memory location 0x0015c87b..

My code that generates this error is

if((dwStatus!= 302) && (dwStatus< 200 || dwStatus> 299))
    throw false;

Here dwStatus is a DWORD which got from pHttpFile->QueryInfoStatusCode(dwStatus) where pHttpFile is an object reference of CHttpFile

The codes are in a try block and appropriate catch blocks are also there.

How this error occurs.

EDIT

This is the catch block

catch(CException* pErr)
{
    TCHAR szErr[1024];
    pErr->GetErrorMessage(szErr,1024);
    pErr->Delete();
    bRet = FALSE;
}
도움이 되었습니까?

해결책

Your catch block is catching a CException* type of exception, but you are throwing a bool type of exception. If you want to catch that exception, you'll need a catch block that catches exceptions of type bool:

catch(bool exception)
{
  //report the exception, or recover, or whatever
}

다른 팁

The exception is caused by your throw. That's what throw is supposed to do. If your question is about why the exception is not caught, then please edit your question and post your catch code.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top