Improved error handling for program.cpp.