I'm relatively new to C++ and I am just wondering, what are the main differences between just throwing an exception or writing std::cerr and exit()? I know that if a exception isn't caught the program will exit. Are there any use cases for std::cerr or should I always throw exceptions? Or should I never use std::cerr in general? Are there some best practices for this?
throw std::runtime_error("runtime error msg");
OR
std::cerr << "cerr error msg";
exit(1);
Are both versions OK?