add helpful error message for dimension violation