Fixed incorrect error message in TypeError exception

The type of the wrong variable was being returned