Created
July 16, 2020 14:46
-
-
Save beachside-project/30a3c94337e069209165208e2013f522 to your computer and use it in GitHub Desktop.
EchoBot: change to Adaptive Dialogs - AdapterWithErrorHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AdapterWithErrorHandler : BotFrameworkHttpAdapter | |
{ | |
public AdapterWithErrorHandler(IConfiguration configuration, | |
IStorage storage, UserState userState, | |
ConversationState conversationState, | |
ILogger<BotFrameworkHttpAdapter> logger) : base(configuration, logger) | |
{ | |
Use(new RegisterClassMiddleware<IConfiguration>(configuration)); | |
this.UseStorage(storage); | |
this.UseBotState(userState); | |
this.UseBotState(conversationState); | |
OnTurnError = async (turnContext, exception) => | |
{ | |
// Log any leaked exception from the application. | |
logger.LogError(exception, $"[OnTurnError] unhandled error : {exception.Message}"); | |
// Send a message to the user | |
await turnContext.SendActivityAsync("The bot encountered an error or bug."); | |
await turnContext.SendActivityAsync("To continue to run this bot, please fix the bot source code."); | |
// Send a trace activity, which will be displayed in the Bot Framework Emulator | |
await turnContext.TraceActivityAsync("OnTurnError Trace", exception.Message, "https://www.botframework.com/schemas/error", "TurnError"); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment