Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
support to skip reject exceptions; fixes microsoft/vscode#1746
Browse files Browse the repository at this point in the history
  • Loading branch information
weinand committed Oct 21, 2016
1 parent 6207c88 commit c8aa971
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/node/nodeDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export class NodeDebugSession extends DebugSession {
private _entryLine: number; // entry line in *.js file (not in the source file)
private _entryColumn: number; // entry column in *.js file (not in the source file)
private _smartStepCount = 0;

private _catchRejects = false;

public constructor() {
super();
Expand Down Expand Up @@ -432,8 +432,22 @@ export class NodeDebugSession extends DebugSession {
let reason: string;
let exception_text: string;

// in order to identify reject calls and debugger statements extract source at current location
let source: string = null;
if (eventBody.sourceLineText && typeof eventBody.sourceColumn === 'number') {
source = eventBody.sourceLineText.substr(eventBody.sourceColumn);
}

// is exception?
if (eventBody.exception) {

// if this is exception originates from a 'reject', skip it
if (!this._catchRejects && source && source.indexOf('reject') == 0) {
this._node.command('continue');
return;
}

// remember exception
this._exception = eventBody.exception;
exception_text = eventBody.exception.text;
reason = this._reasonText('exception');
Expand Down Expand Up @@ -467,8 +481,7 @@ export class NodeDebugSession extends DebugSession {

// is debugger statement?
if (!reason) {
const sourceLine = eventBody.sourceLineText;
if (sourceLine && sourceLine.indexOf('debugger') >= 0) {
if (source && source.indexOf('debugger') == 0) {
reason = this._reasonText('debugger');
this._gotDebuggerEvent = true;
}
Expand Down Expand Up @@ -1781,10 +1794,12 @@ export class NodeDebugSession extends DebugSession {
type: 'all',
enabled: false
};
this._catchRejects = false;
const filters = args.filters;
if (filters) {
if (filters.indexOf('all') >= 0) {
nodeArgs.enabled = true;
this._catchRejects = true;
} else if (filters.indexOf('uncaught') >= 0) {
nodeArgs.type = 'uncaught';
nodeArgs.enabled = true;
Expand Down

0 comments on commit c8aa971

Please sign in to comment.