Added exception handling to pdo iterator