This is an example of what I often do when I want to add some information to an exception:
std::stringstream errMsg;
errMsg << \"Could not load config
The standard exceptions can be constructed from a std::string:
#include
char const * configfile = "hardcode.cfg";
std::string const anotherfile = get_file();
throw std::runtime_error(std::string("Failed: ") + configfile);
throw std::runtime_error("Error: " + anotherfile);
Note that the base class std::exception can not be constructed thus; you have to use one of the concrete, derived classes.