Properly catch exceptions