The code currently writes a message to stderr, then calls exit if an error occurs. Throwing an std::exception instead would be a more robust and standard behavior, as it permits proper destruction of data structures owned by the caller, as well as reacting to the error with application-specific messages or with custom behaviors.
The code currently writes a message to stderr, then calls exit if an error occurs. Throwing an std::exception instead would be a more robust and standard behavior, as it permits proper destruction of data structures owned by the caller, as well as reacting to the error with application-specific messages or with custom behaviors.