I want to throw multiple (2) different string exceptions and I want them to be caught by 2 separate catches, how can I accomplish this?
try
{
std::istringstream ss2(argv[i]);
if (!(ss2 >> l)) throw (std::string)"abc";
if(l < 0 || l > n) throw (std::string)"xyz";
}
catch(std::string abc) {
do something for abc
}
catch(std::string xyz){
do something for xyz
}
Code above would always fire the first catch and never the second.