Catching exceptions in main class