Improve error messages for type functions