Fix error checking in solve_affine_equations