Check for OSError to handle listdir failure