Make the primitive collections visitors generic over Exception types.

Addressing one of the higher-risk concerns from #3477