Skip to content

Commit cb50de9

Browse files
committed
added logging of exceptions
1 parent c40da97 commit cb50de9

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎v3/js/opt-frontend-common.js‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,8 @@ function executePythonCode(pythonSourceCode,
12351235
function execCallback(dataFromBackend) {
12361236
var trace = dataFromBackend.trace;
12371237

1238+
var killerException = null;
1239+
12381240
// don't enter visualize mode if there are killer errors:
12391241
if (!trace ||
12401242
(trace.length == 0) ||
@@ -1243,9 +1245,11 @@ function executePythonCode(pythonSourceCode,
12431245
handleUncaughtExceptionFunc(trace);
12441246

12451247
if (trace.length == 1) {
1248+
killerException = trace[0]; // killer!
12461249
setFronendError([trace[0].exception_msg]);
12471250
}
12481251
else if (trace[trace.length - 1].exception_msg) {
1252+
killerException = trace[trace.length - 1]; // killer!
12491253
setFronendError([trace[trace.length - 1].exception_msg]);
12501254
}
12511255
else {
@@ -1279,9 +1283,14 @@ function executePythonCode(pythonSourceCode,
12791283

12801284
// debounce to compress a bit ... 250ms feels "right"
12811285
$.doTimeout('updateOutputLogEvent', 250, function() {
1282-
logEvent({type: 'updateOutput', step: args.myViz.curInstr,
1283-
curline: args.myViz.curLineNumber,
1284-
prevline: args.myViz.prevLineNumber});
1286+
var obj = {type: 'updateOutput', step: args.myViz.curInstr,
1287+
curline: args.myViz.curLineNumber,
1288+
prevline: args.myViz.prevLineNumber};
1289+
// optional field
1290+
if (args.myViz.curLineExceptionMsg !== undefined) {
1291+
obj.exception = args.myViz.curLineExceptionMsg;
1292+
}
1293+
logEvent(obj);
12851294
});
12861295

12871296
// 2014-05-25: implemented more detailed tracing for surveys
@@ -1328,6 +1337,7 @@ function executePythonCode(pythonSourceCode,
13281337
backendDataJSON: JSON.stringify(dataFromBackend), // for easier transport and compression
13291338
frontendOptionsObj: frontendOptionsObj,
13301339
backendOptionsObj: backendOptionsObj,
1340+
killerException: killerException, // if there's, say, a syntax error
13311341
});
13321342
}
13331343

‎v3/js/pytutor.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,8 @@ ExecutionVisualizer.prototype.updateOutputFull = function(smoothTransition) {
14271427
return;
14281428
}
14291429

1430+
myViz.curLineExceptionMsg = undefined; // reset!
1431+
14301432

14311433
// really nitpicky!!! gets the difference in width between the code display
14321434
// and the maximum width of its enclosing div
@@ -1565,6 +1567,7 @@ ExecutionVisualizer.prototype.updateOutputFull = function(smoothTransition) {
15651567
myViz.domRoot.find("#errorOutput").show();
15661568

15671569
hasError = true;
1570+
myViz.curLineExceptionMsg = curEntry.exception_msg;
15681571
}
15691572
else {
15701573
if (!this.instrLimitReached) { // ugly, I know :/

0 commit comments

Comments
 (0)