Update main.cpp

error handling