Properly raise exception when template function is not defined.