Answers for "C++ add value to exception message"

C++
1

C++ add value to exception message

//some exceptions accept a string, so it's easy
throw std::invalid_argument("INVALID VALUE : " + std::to_string(val));

//if it only accept char* you'd have to do something like this
throw std::except( (std::string("ERROR VALUE ") + std::to_string(val)).c_str() )
Posted by: Guest on May-04-2022

Code answers related to "C++ add value to exception message"

Browse Popular Code Answers by Language