Catch exceptions and log