Skip to content

Commit

Permalink
Removed fallback exception from version change logic. (#2283)
Browse files Browse the repository at this point in the history
* Removed fallback exception from version cgange logic.

* Removed un-needed unit test

* Removed console log

Co-authored-by: Steven Gum <14935595+stevengum@users.noreply.github.com>
  • Loading branch information
Stevenic and stevengum committed Jun 1, 2020
1 parent cad3701 commit f3e7e02
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 47 deletions.
6 changes: 1 addition & 5 deletions libraries/botbuilder-dialogs/src/dialogContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ export abstract class DialogContainer<O extends object = {}> extends Dialog<O> {
// Give bot an opportunity to handle the change.
// - If bot handles it the changeHash will have been updated as to avoid triggering the
// change again.
const handled = await dc.emitEvent(DialogEvents.versionChanged, this.id, true, false);
if (!handled) {
// Throw an error for bot to catch
throw new Error(`Version change detected for '${this.id}' dialog.`);
}
await dc.emitEvent(DialogEvents.versionChanged, this.id, true, false);
}
}
}
42 changes: 0 additions & 42 deletions libraries/botbuilder-dialogs/tests/componentDialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,48 +391,6 @@ describe('ComponentDialog', function () {
.assertReply('Second step.')
.assertReply('Done.')
});

it('should throw error if unhandled dialogChange event.', (done) => {
const conversationState = new ConversationState(new MemoryStorage());
const dialogState = conversationState.createProperty('dialog');

const childDialog = new WaterfallDialog('child', [
async step => {
component.addDialog(new WaterfallDialog('change'));
await step.context.sendActivity('First step.');
return Dialog.EndOfTurn;
},
async step => {
await step.context.sendActivity('Second step.');
return await step.endDialog();
}
]);
const component = new ChangedDialog('test', false);
component.addDialog(childDialog);

const dialogs = new DialogSet(dialogState);
dialogs.add(component);

const adapter = new TestAdapter(async turnContext => {
try {
const dc = await dialogs.createContext(turnContext);
const results = await dc.continueDialog();

if (results.status === DialogTurnStatus.empty) {
await dc.beginDialog('test');
}
await conversationState.saveChanges(turnContext);
} catch (err) {
await turnContext.sendActivity('Done.')
done();
}
});

adapter.send('Hi')
.assertReply('First step.')
.send('Hi again')
.assertReply('Done.')
});
});


Expand Down

0 comments on commit f3e7e02

Please sign in to comment.