[Question] Dialog state lost on exception
We implemented global exception handling for our bot that works as expected, except if a Dialog currently throws and exception it's state is lost.
How can we ensure a Dialog is still serialized even if it throws and exception?
@DL-LiveTiles Are you using .NET or Node SDK?
@nwhitmont .NET SDK. Sorry, will remember to add next time.
Any insight on how to persist Dialog state after an exception?
@DL-LiveTiles Have you tried anything that uses a more permanent storage method? Maybe save the state to a db with the username or any other useful data?
@JasonSowers No, using the built-in Dialog state. Is rolling your own custom state the recommended way? I don't need more permanent storage, I would just like the Dialog to not lose state on an exception.
Implemented custom Azure Storage for bot data using BotBuilder-Azure, but the issue still persists.
@DL-LiveTiles can you share your implementation?
@JasonSowers I cannot share my version, but here is a sample: https://github.com/Microsoft/BotBuilder-Azure/tree/master/CSharp/Samples/AzureTable
Hi @DL-LiveTiles
Please provide a bare-bones example of the behavior you're seeing.
I spoke with the engineers who wrote the dialog stack, and they pointed out that "The stack and data bags get persisted even if there is an exception thrown by the dialogs in the stack: https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Microsoft.Bot.Builder/Dialogs/DialogTask.cs#L485
They also stated: "The problem that you are seeing is that the exceptions bubble up through the stack until a dialog on the stack handles the exception, if not it reaches the root loop dialog. This means that the conversation is reset to the initial state (dialog stack) because of the unhandled exception."
Please reopen this issue if needed
Hi @EricDahlvang,
Sorry for only getting back to you now, I was on another project and did not have time to look into this again.
What is the best way of globally handling exceptions on a dialog so that the exception does not bubble up and reset the initial state?
Thank you,
Douw
Hi @DL-LiveTiles
You'll need to catch the exception in the dialog's code, and handle it there.