0
我有4個對話框,每個對話框在小孩滿足特定條件時產生。 當我在本地測試時,一切正常,但當我發佈到天藍色時,它不會。 我得到一個一般性錯誤:微軟Bot框架退出對話框並處理父母
Sorry, my bot code is having an issue.
我相信我已經確定了問題所在,所以我想將消息發佈到客戶端,然後退出一切。 我有這樣的方法:
/// <summary>
/// Gets our products
/// </summary>
/// <returns></returns>
private async Task<List<ProductResponseModel>> GetCurrentProducts(IDialogContext context)
{
try
{
// If we don't have any products, get them
if (_products == null)
_products = await _productProvider.ListAsync();
} catch (Exception ex)
{
// Throw our error
await context.PostAsync(ex.Message);
// Exit our dialog
await ResumeAfter(context, null);
}
// Return our filtered products
return _products;
}
/// <summary>
/// When the child dialog has completed, mark this as done
/// </summary>
/// <param name="context">The current context</param>
/// <param name="result">The result object</param>
/// <returns></returns>
private async Task ResumeAfter(IDialogContext context, IAwaitable<object> result) => context.Done<IMessageActivity>(null);
如果有錯誤,它應該發佈錯誤消息給用戶,然後它調用ResumeAfter它調用context.Done
。我相信應該結束當前的對話和其他所有的對話。這是正確的嗎?或者有另一種方式我應該這樣做。我的所有對話實現IDialog<object>
我不能有產品在try catch塊的回報,因爲它的呻吟聲,並非所有的代碼路徑返回一個結果(即使使用context.Fail時)。除此之外,你建議的一切都很棒。 – r3plica