C# bot framework异常似乎在模拟器和botframework网站上的网络聊天测试之间没有得到正确处理
C# bot framework exception seem to be not handled properly between the emulator and the web chat test on the botframework website
到目前为止,我有以下代码可用于检查 LUIS JSON 响应是否包含实体
public static class StatusHelper
{
public static bool EntityCheck(LuisResult result)
{
try
{
var statuscheck = result.Entities[0].Entity;
return true;
} catch (Exception)
{
return false;
}
}
}
在我使用的另一个文件中
if (StatusHelper.EntityCheck(LuisResult result))
{
//code
}
else
{
await context.PostAsync("No Entities");
}
在我的机器人模拟器中,如果没有找到实体,机器人会说
No Entities
但是在 dev.botframework.com 网站上它会说
Sorry, my bot code is having an issue.
我不确定这里发生了什么
为什么要使用异常抛出来测试是否有值?
你不能只检查你的结果和数组中的一些实体,然后检查第一个实体是否不为空,如下所示:
public static bool EntityCheck(LuisResult result)
{
return (result.Entities.Count > 0 && result.Entities[0].Entity != null);
}
到目前为止,我有以下代码可用于检查 LUIS JSON 响应是否包含实体
public static class StatusHelper
{
public static bool EntityCheck(LuisResult result)
{
try
{
var statuscheck = result.Entities[0].Entity;
return true;
} catch (Exception)
{
return false;
}
}
}
在我使用的另一个文件中
if (StatusHelper.EntityCheck(LuisResult result))
{
//code
}
else
{
await context.PostAsync("No Entities");
}
在我的机器人模拟器中,如果没有找到实体,机器人会说
No Entities
但是在 dev.botframework.com 网站上它会说
Sorry, my bot code is having an issue.
我不确定这里发生了什么
为什么要使用异常抛出来测试是否有值? 你不能只检查你的结果和数组中的一些实体,然后检查第一个实体是否不为空,如下所示:
public static bool EntityCheck(LuisResult result)
{
return (result.Entities.Count > 0 && result.Entities[0].Entity != null);
}