Skip to content

Commit

Permalink
feat: allow pause on conditional exception
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 committed Jan 4, 2021
1 parent 55f9150 commit 848c81a
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
## TBA

- feat: allow debugging node worker_threads
- feat: allow pausing on conditional exceptions ([ref](https://github.com/microsoft/vscode/issues/104453))
- feat: make the line on log messages take into account skipFiles ([#882](https://github.com/microsoft/vscode-js-debug/issues/882))
- fix: persist state in the diagnostic tool ([#879](https://github.com/microsoft/vscode-js-debug/issues/879))
- fix: allow outdated node dialog to be bypassed ([ref](https://github.com/microsoft/vscode/issues/111642))
Expand Down
2 changes: 1 addition & 1 deletion src/test/node/node-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('node runtime', () => {
});

await handle.dap.setExceptionBreakpoints({
filters: ['caught', 'uncaught'],
filters: ['all', 'uncaught'],
});

handle.dap.on('output', o => handle.logger.logOutput(o));
Expand Down
2 changes: 1 addition & 1 deletion src/test/stacks/stacksTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('stacks', () => {

itIntegrates('does not smart step on exception breakpoints', async ({ r }) => {
const p = await r.launchUrlAndLoad('index.html');
await p.dap.setExceptionBreakpoints({ filters: ['uncaught', 'caught'] });
await p.dap.setExceptionBreakpoints({ filters: ['uncaught', 'all'] });
p.addScriptTag('smartStep/exceptionBp.js');
await dumpStackAndContinue(p, false);
p.assertLog();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Pausing on caught exceptions
Evaluating#1: setTimeout(() => { try { throw new Error('hello'); } catch (e) {} })
Evaluating#2: setTimeout(() => { try { throw new Error('goodbye'); } catch (e) {} })
{
allThreadsStopped : false
description : Paused on exception
reason : exception
threadId : <number>
}
{
breakMode : all
details : {
stackTrace : at eval2.js:1:32
}
exceptionId : Error: goodbye
}
{
allThreadsContinued : false
}
Pausing on uncaught exceptions
Evaluating#3: setTimeout(() => { throw new Error('hello'); })
Evaluating#4: setTimeout(() => { try { throw new Error('goodbye1'); } catch (e) {} })
Evaluating#5: setTimeout(() => { throw new Error('goodbye2'); })
{
allThreadsStopped : false
description : Paused on exception
reason : exception
threadId : <number>
}
{
breakMode : all
details : {
stackTrace : at eval5.js:1:26
}
exceptionId : Error: goodbye2
}
{
allThreadsContinued : false
}
27 changes: 26 additions & 1 deletion src/test/threads/threadsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,39 @@ describe('threads', () => {
await waitForPauseOnException(p);

p.log('Pausing on caught exceptions');
await p.dap.setExceptionBreakpoints({ filters: ['caught'] });
await p.dap.setExceptionBreakpoints({ filters: ['all'] });
p.evaluate(`setTimeout(() => { throw new Error('hello'); })`);
await waitForPauseOnException(p);
p.evaluate(`setTimeout(() => { try { throw new Error('hello'); } catch (e) {}})`);
await waitForPauseOnException(p);
p.assertLog();
});

itIntegrates('pauses on conditional exceptions', async ({ r }) => {
const p = await r.launchAndLoad('blank');

p.log('Pausing on caught exceptions');
await p.dap.setExceptionBreakpoints({
filters: ['all'],
filterOptions: [{ filterId: 'all', condition: 'error.message.includes("bye")' }],
});
p.evaluate(`setTimeout(() => { try { throw new Error('hello'); } catch (e) {} })`);
p.evaluate(`setTimeout(() => { try { throw new Error('goodbye'); } catch (e) {} })`);
await waitForPauseOnException(p);

p.log('Pausing on uncaught exceptions');
await p.dap.setExceptionBreakpoints({
filters: ['uncaught'],
filterOptions: [{ filterId: 'uncaught', condition: 'error.message.includes("bye")' }],
});
p.evaluate(`setTimeout(() => { throw new Error('hello'); })`);
p.evaluate(`setTimeout(() => { try { throw new Error('goodbye1'); } catch (e) {} })`);
p.evaluate(`setTimeout(() => { throw new Error('goodbye2'); })`);
await waitForPauseOnException(p);

p.assertLog();
});

itIntegrates('configuration', async ({ r }) => {
const p = await r.launch(`
<script>
Expand Down

0 comments on commit 848c81a

Please sign in to comment.