Skip to content

Commit

Permalink
Merge pull request #647 from Shreyas-vgr/2.0.x
Browse files Browse the repository at this point in the history
(ask-sdk-controls) Updated ControlManager responseBuilder type
  • Loading branch information
Shreyas-vgr committed Aug 20, 2020
2 parents ad67fa0 + 8120f93 commit f029dc7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
10 changes: 2 additions & 8 deletions ask-sdk-controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
"dependencies": {
"ask-sdk-core": "^2.8.0",
"ask-sdk-model": "^1.28.0",
"ask-sdk-runtime": "^2.8.0",
"ask-smapi-model": "^1.5.0",
"i18next": "^19.5.4",
"debug": "^4.1.1",
"lodash": "^4.17.15",
"tslib": "^2.0.0",
"chai": "^4.2.0"
"chai": "^4.2.0",
"tslib": "^2.0.0"
},
"devDependencies": {
"@types/chai": "^4.2.8",
Expand All @@ -39,14 +38,9 @@
"@typescript-eslint/parser": "^3.3.0",
"cross-env": "^7.0.2",
"eslint": "^7.2.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-prefer-arrow": "^1.2.1",
"eslint-plugin-tsdoc": "^0.2.5",
"mocha": "^7.1.2",
"mocha-typescript": "^1.1.17",
"nyc": "^15.0.1",
"uuid": "^3.4.0",
"sinon": "^9.0.1",
"source-map-support": "^0.5.16",
"ts-node": "^8.6.2",
Expand Down
3 changes: 1 addition & 2 deletions ask-sdk-controls/src/controls/ControlManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* permissions and limitations under the License.
*/

import { ResponseBuilder } from 'ask-sdk-core';
import i18next, { Resource } from 'i18next';
import _ from "lodash";
import { systemResource } from '../commonControls/LanguageStrings';
Expand Down Expand Up @@ -175,7 +174,7 @@ export abstract class ControlManager implements IControlManager {
* @param error - Error
* @param responseBuilder - Response builder
*/
handleInternalError(input: ControlInput, error: any, responseBuilder: ResponseBuilder): void {
handleInternalError(input: ControlInput, error: any, responseBuilder: ControlResponseBuilder): void {
const err = error.stack !== undefined ? { name: error.name, msg: error.message, stack: error.stack } : error; // Error doesn't have enumerable properties, so we convert it.
log.error(`Error handled: ${JSON.stringify(err)}`);
}
Expand Down
6 changes: 3 additions & 3 deletions ask-sdk-controls/src/controls/interfaces/IControlManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
* permissions and limitations under the License.
*/

import { ResponseBuilder } from 'ask-sdk-core';
import { IControlResult } from './IControlResult';
import { IControl } from './IControl';
import { IControlInput } from './IControlInput';
import { ControlResponseBuilder } from '../../responseGeneration/ControlResponseBuilder';

/**
* Manages a skill built with Controls.
Expand Down Expand Up @@ -53,11 +53,11 @@ export interface IControlManager {
* @param input - Input
* @param responseBuilder - Response builder
*/
render(result: IControlResult, input: IControlInput, responseBuilder: ResponseBuilder): void | Promise<void>;
render(result: IControlResult, input: IControlInput, responseBuilder: ControlResponseBuilder): void | Promise<void>;

/**
* Custom handling of a internal error before the skill exits and closes the
* user session.
*/
handleInternalError?(input: IControlInput, error: any, responseBuilder: ResponseBuilder): void;
handleInternalError?(input: IControlInput, error: any, responseBuilder: ControlResponseBuilder): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

import { ui, Intent, interfaces, Directive, Response, dialog, canfulfill } from "ask-sdk-model";
import { ResponseBuilder, ResponseFactory } from 'ask-sdk-core';
import { ResponseBuilder } from 'ask-sdk-core';


/**
Expand Down
4 changes: 2 additions & 2 deletions ask-sdk-controls/src/runtime/ControlHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class ControlHandler implements RequestHandler {
}
catch (error) {
if (this.controlManager.handleInternalError) {
this.controlManager.handleInternalError(this.controlInput, error, handlerInput.responseBuilder);
this.controlManager.handleInternalError(this.controlInput, error, new ControlResponseBuilder(handlerInput.responseBuilder));
}
throw error; // rethrow so top-level observes it too.
}
Expand Down Expand Up @@ -190,7 +190,7 @@ export class ControlHandler implements RequestHandler {
}
catch (error) {
if (this.controlManager.handleInternalError) {
this.controlManager.handleInternalError(this.controlInput, error, handlerInput.responseBuilder);
this.controlManager.handleInternalError(this.controlInput, error, new ControlResponseBuilder(handlerInput.responseBuilder));
}

return { ...handlerInput.responseBuilder.getResponse(), isTurnEnding: true };
Expand Down

0 comments on commit f029dc7

Please sign in to comment.