Satbir
Satbir

Reputation: 6506

Does catch(...) actually catch all exceptions?

I see catch (...) does not catch all the exceptions and an annoying pop is thrown on end user.

size_t pos;
char *ptrDir="c:\\test";
std::string strDir = 
strDir.erase(strlen(ptrDir) - 1);
pos = strDir.find("Test");
try
{
    std::string strPat = strDir.substr(pos);
}
catch(...)
{
    std::cout<<"I am hiding Exception";
}

I am using Visual Studio 2005, Windows XP.

Note: Code is intentional to generate exceptions. It's a test code

Upvotes: 2

Views: 216

Answers (1)

wkl
wkl

Reputation: 80001

Your code will likely generate access violations, which in VC++ are not going to be standard exceptions, they are in the realm of Structured Exceptions, which you can also catch but will need to use a different mechanism:

Upvotes: 7

Related Questions