C++ add value to exception message

Asked  May 25, 07:53 pm 59 Views Add Your Answer
Asked  May 25, 07:53 pm
C++
0 Dislikes
0 Comments

1 Answers

Added  May 27, 07:55 am

//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() )

0 Likes 0 Dislikes
0 Comments
×
Google login
SignUp with Email
X