Pregunta

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;
}
¿Fue útil?

Solución

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
}

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top