Skip to content

Instantly share code, notes, and snippets.

@beachside-project
Created July 16, 2020 14:46
Show Gist options
  • Save beachside-project/30a3c94337e069209165208e2013f522 to your computer and use it in GitHub Desktop.
Save beachside-project/30a3c94337e069209165208e2013f522 to your computer and use it in GitHub Desktop.
EchoBot: change to Adaptive Dialogs - AdapterWithErrorHandler
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