Add error handling to program.cpp