Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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() )
 
PREVIOUS NEXT
Tagged: #add #exception #message
ADD COMMENT
Topic
Name
8+2 =