IgnoreCollisions Exception

I am using this code to force objects to ignore collisions on an array of other objects:

ballList = GameObject.FindGameObjectsWithTag("ball"); 
for (ball in ballList)
{ 
    Physics.IgnoreCollision(ball.collider, collider); 
} 

When I run the game I get this exception:

Scene::setShapePairFlags: The two shape references must not reference the same shape. UnityEngine.Physics:IgnoreCollision(Collider, Collider, Boolean) UnityEngine.Physics:IgnoreCollision(Collider, Collider, Boolean) UnityEngine.Physics:IgnoreCollision(Collider, Collider)

What does this mean and how can it be fixed?

Change

Physics.IgnoreCollision(ball.collider, collider);

to

if (ball.collider != collider) {
    Physics.IgnoreCollision(ball.collider, collider);
}

Your `ball` is the same game object that the script is on, so `ball.collider` and `collider` are exactly the same component. I don't know how to fix it, but you can't give `IgnoreCollisions()` the same reference twice.

Or you could have just read the error message, which explains exactly what I just said:

The two shape references must not reference the same shape.