Unhandled exception, even after adding try-catch block ? C++
Posted
by
user2525503
on Stack Overflow
See other posts from Stack Overflow
or by user2525503
Published on 2014-06-12T09:16:08Z
Indexed on
2014/06/12
9:24 UTC
Read the original article
Hit count: 176
try
{
bool numericname=false;
std::cout <<"\n\nEnter the Name of Customer: ";
std::getline(cin,Name);
std::cout<<"\nEnter the Number of Customer: ";
std::cin>>Number;
std::string::iterator i=Name.begin();
while(i!=Name.end())
{
if(isdigit(*i))
{
numericname=true;
}
i++;
}
if(numericname)
{
throw "Name cannot be numeric.";
}
} catch(string message)
{
cout<<"\nError Found: "<< message <<"\n\n";
}
Why am I getting unhandled exception error ? Even after I have added the catch block to catch thrown string messages?
© Stack Overflow or respective owner