Unhandled exception, even after adding try-catch block ? C++
- by user2525503
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?