Factored out TypeError