catch exceptions in main.cc