C++ runtime, display exception message
You could write in main:
try{
}catch(const std::exception &e){
std::cerr << e.what() << std::endl;
throw;
}
You could use try/catch
block and throw;
statement to let library user to handle the exception. throw;
statement passes control to another handler for the same exception.
Standard exceptions have a virtual what()
method that gives you the message associated with the exception:
int main() {
try {
// your stuff
}
catch( const std::exception & ex ) {
cerr << ex.what() << endl;
}
}