summaryrefslogtreecommitdiff
path: root/js/codeq/prolog.js
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-09-23 12:12:37 +0200
committerTimotej Lazar <timotej.lazar@araneo.org>2015-09-23 12:12:37 +0200
commit6e8d9772baff4fd2e58c005bb6358d29113100ad (patch)
tree0257b8699f8f47666f763eeb2fb3b07c559d30d5 /js/codeq/prolog.js
parent9be012f126f6926c51ff679f7de5458bf2cececc (diff)
Improve error handling for button actions
Diffstat (limited to 'js/codeq/prolog.js')
-rw-r--r--js/codeq/prolog.js41
1 files changed, 20 insertions, 21 deletions
diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js
index d01cc54..66ab970 100644
--- a/js/codeq/prolog.js
+++ b/js/codeq/prolog.js
@@ -259,7 +259,10 @@
editor = CodeMirror(jqEditor[0], { cursorHeight: 0.85, lineNumbers: true, matchBrackets: true }),
activityHandler = makeActivityHandler(editor, problem.id),
terminal = makePrologTerminalHandler(jqTerminal, editor, problem.id, activityHandler),
- hinter = codeq.makeHinter(jqHints, jqEditor, editor, problem.hint, problem.plan);
+ hinter = codeq.makeHinter(jqHints, jqEditor, editor, problem.hint, problem.plan),
+ commError = function (error) {
+ alert(error);
+ };
editor.setValue(info.solution);
$('#title').text(problem.slug);
@@ -293,17 +296,15 @@
'program': editor.getDoc().getValue(),
'problem_id': problem.id
})
- .then(
- function hintSuccess(data) {
- if (data.code === 0)
- hinter.handle(data.hints);
- else
- terminal.append(data.message + '\n', 'error');
- },
- function hintFailed (error) {
- terminal.append(error + '\n', 'error');
+ .then(function (data) {
+ if (data.code === 0) {
+ hinter.handle(data.hints);
+ }
+ else {
+ terminal.append(data.message + '\n', 'error');
}
- )
+ })
+ .fail(commError)
.fin(function () {
terminal.inputEnable();
terminal.append('?- ', 'output');
@@ -319,17 +320,15 @@
'program': editor.getDoc().getValue(),
'problem_id': problem.id
})
- .then(
- function testSuccess(data) {
- if (data.code === 0)
- hinter.handle(data.hints);
- else
- terminal.append(data.message + '\n', 'error');
- },
- function testFailed (error) {
- terminal.append(error + '\n', 'error');
+ .then(function (data) {
+ if (data.code === 0) {
+ hinter.handle(data.hints);
}
- )
+ else {
+ terminal.append(data.message + '\n', 'error');
+ }
+ })
+ .fail(commError)
.fin(function () {
terminal.inputEnable();
terminal.append('?- ', 'output');