Handle exceptions and timeouts