Improve error message generator for type mismatches