Skip to content

Commit

Permalink
Train Almond: catch syntax errors inside the promise
Browse files Browse the repository at this point in the history
So we can report them to the user

Fixes #23
  • Loading branch information
gcampax committed Oct 25, 2018
1 parent d7bb3c9 commit 512a903
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion browser/new-command.js
Expand Up @@ -173,7 +173,9 @@ class ThingTalkTrainer {
} else {
let thingtalk = $('#input-command-thingtalk').val();
if (thingtalk.length > 0) {
this._learnThingTalk(thingtalk).then(() => {
Promise.resolve().then(() => {
return this._learnThingTalk(thingtalk);
}).then(() => {
$('#thingtalk-group').removeClass('has-error');
$('#thingtalk-error').text('');
this._updateConfirmation();
Expand Down
4 changes: 3 additions & 1 deletion browser/trainer.js
Expand Up @@ -170,7 +170,9 @@ class ThingTalkTrainer {
event.preventDefault();

var tt = $('#thingtalk').val();
this._learnThingTalk(tt).then((data) => {
Promise.resolve().then(() => {
return this._learnThingTalk(tt);
}).then((data) => {
$('#results-container').hide();
$('#thingtalk-editor').addClass('hidden');
$('#thingtalk-group').removeClass('has-error');
Expand Down

0 comments on commit 512a903

Please sign in to comment.