I have a class which inherits from std::runtime_error like so:
#include <string>
#include <stdexcept>
class SomeEx : public std::runtime_error
{
public:
SomeEx(const std::string& msg) : runtime_error(msg) { }
};
Said msg will always be something like “invalid type ID 43”. Is there any way to build that “what string” with another constructor (or another method) so that I provide only the integer type ID? Something like:
SomeEx(unsigned int id) {
// set what string to ("invalid type ID " + id)
}
unrelated: the reason we have string
.what()is so that people STOP USING ERROR NUMBERS.