Repaired error handling