Skip to content

Commit cd64887

Browse files
committed
debugger: throw debugger error when the frame is missing
1 parent b008e96 commit cd64887

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/internal/debugger/inspect_repl.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,9 @@ function createRepl(inspector) {
635635

636636
// List source code
637637
function list(delta = 5) {
638+
if (!selectedFrame) {
639+
throw new ERR_DEBUGGER_ERROR('Requires execution to be paused');
640+
}
638641
return selectedFrame.list(delta).then(null, (error) => {
639642
print("You can't list source code right now");
640643
throw error;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
common.skipIfInspectorDisabled();
5+
6+
const fixtures = require('../common/fixtures');
7+
const startCLI = require('../common/debugger');
8+
9+
const assert = require('assert');
10+
11+
const cli = startCLI([fixtures.path('debugger/three-lines.js')]);
12+
13+
cli.waitForInitialBreak()
14+
.then(() => cli.waitForPrompt())
15+
.then(() => cli.command('list(0)'))
16+
.then(() => {
17+
assert.match(cli.output, /> 1 let x = 1;/);
18+
})
19+
.then(() => cli.command('list(1)'))
20+
.then(() => {
21+
assert.match(cli.output, /> 1 let x = 1;\n {2}2 x = x \+ 1;/);
22+
})
23+
.then(() => cli.command('list(10)'))
24+
.then(() => {
25+
assert.match(cli.output, /> 1 let x = 1;\n {2}2 x = x \+ 1;\n {2}3 module\.exports = x;\n {2}4 /);
26+
})
27+
.then(() => cli.command('c'))
28+
.then(() => cli.waitFor(/disconnect/))
29+
.then(() => cli.waitForPrompt())
30+
.then(() => cli.command('list()'))
31+
.then(() => {
32+
assert.match(cli.output, /Uncaught Error \[ERR_DEBUGGER_ERROR\]: Requires execution to be paused/);
33+
})
34+
.finally(() => cli.quit())
35+
.then(common.mustCall());

0 commit comments

Comments
 (0)