Better error message for casting method