Add type_check_raise() function and remove duplicate code