I would like to be able to catch different logic_errors and be able to differentiate them. Can I somehow pass additional parameters to the logical error which to catch later. The idea is that I need to print. Right now I am just catching the default errors that stof can return.
"Sorry invalid temperature" or "Sorry invalid rainfall"
P.S. The function stringToTime converts dates to strings and throws logic error with some text, if the date doesn't match certain criteria. Thank you!
try{
tm date = stringToTime(year);
float temp = stof(temperature);
float rain = stof(rainfall);
}
catch(logic_error e){
if( string(e.what()) == "stof"){
cout << "Sorry wrong arguments for either Temperature or Rainfall" << endl;
}else{
cout << e.what() << endl;
}
}