Skip to content

Commit 1eb8f83

Browse files
committed
add better error messages for setImmediate/Interval/Timeout not supported
1 parent 52a6b71 commit 1eb8f83

7 files changed

Lines changed: 73 additions & 1 deletion

File tree

‎v4-cokapi/backends/javascript/jslogger.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,13 @@ try {
10901090
debug.setBreakOnException(); // for exception handling
10911091
//debug.setBreakOnUncaughtException(); // doesn't seem to do anything :/
10921092

1093-
_eval(wrappedCod, 'userscript.js', {} /* scope */, true /* includeGlobals */);
1093+
var overrideScope = {
1094+
setInterval: () => {throw 'Error: setInterval() is not supported by Python Tutor'},
1095+
setTimeout: () => {throw 'Error: setTimeout() is not supported by Python Tutor'},
1096+
setImmediate: () => {throw 'Error: setImmediate() is not supported by Python Tutor'},
1097+
}
1098+
1099+
_eval(wrappedCod, 'userscript.js', overrideScope /* scope */, true /* includeGlobals */);
10941100
}
10951101
catch (e) {
10961102
// for some reason, the node debugger doesn't allow us to keep going
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{ code: 'setImmediate(() => {console.log("foo")}, 1000);',
2+
trace:
3+
[ { stdout: '',
4+
func_name: '',
5+
stack_to_render: [],
6+
globals: {},
7+
ordered_globals: [],
8+
line: 1,
9+
col: 0,
10+
event: 'step_line',
11+
heap: {} },
12+
{ exception_msg: 'Error: setImmediate() is not supported by Python Tutor',
13+
stdout: '',
14+
func_name: '',
15+
stack_to_render: [],
16+
globals: {},
17+
ordered_globals: [],
18+
line: 1,
19+
col: 0,
20+
event: 'exception',
21+
heap: {} } ] }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
setImmediate(() => {console.log("foo")}, 1000);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{ code: 'setInterval(() => {console.log("foo")}, 1000);',
2+
trace:
3+
[ { stdout: '',
4+
func_name: '',
5+
stack_to_render: [],
6+
globals: {},
7+
ordered_globals: [],
8+
line: 1,
9+
col: 0,
10+
event: 'step_line',
11+
heap: {} },
12+
{ exception_msg: 'Error: setInterval() is not supported by Python Tutor',
13+
stdout: '',
14+
func_name: '',
15+
stack_to_render: [],
16+
globals: {},
17+
ordered_globals: [],
18+
line: 1,
19+
col: 0,
20+
event: 'exception',
21+
heap: {} } ] }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
setInterval(() => {console.log("foo")}, 1000);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{ code: 'setTimeout(() => {console.log("foo")}, 1000);',
2+
trace:
3+
[ { stdout: '',
4+
func_name: '',
5+
stack_to_render: [],
6+
globals: {},
7+
ordered_globals: [],
8+
line: 1,
9+
col: 0,
10+
event: 'step_line',
11+
heap: {} },
12+
{ exception_msg: 'Error: setTimeout() is not supported by Python Tutor',
13+
stdout: '',
14+
func_name: '',
15+
stack_to_render: [],
16+
globals: {},
17+
ordered_globals: [],
18+
line: 1,
19+
col: 0,
20+
event: 'exception',
21+
heap: {} } ] }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
setTimeout(() => {console.log("foo")}, 1000);

0 commit comments

Comments
 (0)