I'd do
```
try:
    z = u.Quantity(z, rho.unit, copy=copy)
except u.UnitsError:
    raise u.UnitsError("rho and z ...")
```