Skip to content

Commit

Permalink
Merge pull request #7 from omenocal/omenocal-patch-1
Browse files Browse the repository at this point in the history
🐛 Fixed unknown intent in state issue
  • Loading branch information
aswetlow authored Aug 8, 2017
2 parents 218424c + a41108f commit 762410a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/jovo.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,18 @@ class Jovo extends EventEmitter {
throw new Error('Error: State ' + this.getState() + ' has not been defined in the handler.');
}

// intent not in state defined, and not global
if (!this.handlers[this.getState()][this.getIntentName()] &&
!this.handlers[this.getIntentName()]) {
throw new Error('Error: The intent ' + this.getState() + ':' + this.getIntentName() + ' has not been defined in the handler');
let intentToRedirect = this.getIntentName();

// intent not in state defined; should return Unhandled
if (!this.handlers[this.getState()][this.getIntentName()]) {
intentToRedirect = 'Unhandled';
}

// handle STATE + Intent
let args = this.getSortedArgumentsInput(
this.handlers[this.getState()][this.getIntentName()]
);
this.handlers[this.getState()][this.getIntentName()]
.apply(this, args);
this.handlers[this.getState()][intentToRedirect].apply(this, args);
}

/**
Expand Down

0 comments on commit 762410a

Please sign in to comment.