- Notifications
You must be signed in to change notification settings - Fork 117
Dialog::run loses exception when innerRun completes exceptionally #1428
Description
Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.
Version
4.14.2
Describe the bug
Suppose an exception is thrown during a step of a waterfall dialog, then this exception should be reflected in the completable future returned by Dialog::run, but in fact Dialog::run returns a future that is completed normally.
To Reproduce
Take the flight booking example.
Replace the code in BookingDialog::destinationStep by
return Async.completeExceptionally(new RuntimeException(„Oops“))
In DialogBot::onMessageActivity add to the return statement
return Dialog.run(…).exceptionally(e -> { e.printStacktrace(); return null; });
Run the bot and send it some flight booking example like „book a flight to London“.
Expected behavior
I would expect the Oops exception stack trace to be printed, but in fact there is nothing.
Screenshots
None.
Additional context
The problem is located in the Dialog::run method. I suggest to change it like this
return dialogSet.createContext(turnContext) .thenCompose(dialogContext -> innerRun(turnContext, dialog.getId(), dialogContext, null)) .thenAccept(dummy -> {});
The crucial thing is to use thenCompose to call innerRun, otherwise its result is essentially ignored.