- Notifications
You must be signed in to change notification settings - Fork 843
/
Copy pathBotHttpAdapter.cs
30 lines (25 loc) · 1.4 KB
/
BotHttpAdapter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) Microsoft Corporation. All rights reserved.
namespaceMicrosoft.Teams.Samples.ConversationalTabs.Web.Bot;
usingMicrosoft.Bot.Builder.Integration.AspNet.Core;
usingMicrosoft.Bot.Builder.TraceExtensions;
usingMicrosoft.Bot.Connector.Authentication;
usingMicrosoft.Extensions.Logging;
publicclassAdapterWithErrorHandler:CloudAdapter
{
publicAdapterWithErrorHandler(BotFrameworkAuthenticationauth,ILogger<IBotFrameworkHttpAdapter>logger)
:base(auth,logger)
{
OnTurnError=async(turnContext,exception)=>
{
// Log any leaked exception from the application.
// NOTE: In production environment, you should consider logging this to
// Azure Application Insights. Visit https://aka.ms/bottelemetry to see how
// to add telemetry capture to your bot.
logger.LogError($"Exception caught : {exception.Message}");
// Uncomment below commented line for local debugging.
// await turnContext.SendActivityAsync($"Sorry, it looks like something went wrong. Exception Caught: {exception.Message}");
// Send a trace activity, which will be displayed in the Bot Framework Emulator
awaitturnContext.TraceActivityAsync("OnTurnError Trace",exception.Message,"https://www.botframework.com/schemas/error","TurnError");
};
}
}