From 3eab07c716979c3e1d355de53763c1b3d63ea45b Mon Sep 17 00:00:00 2001 From: Andre Weinand Date: Thu, 27 Apr 2017 16:34:25 +0200 Subject: [PATCH] tweak what's returned from exceptionInfo request; fixes Microsoft/vscode#21929 for node-debug --- src/node/nodeDebug.ts | 70 +++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/src/node/nodeDebug.ts b/src/node/nodeDebug.ts index 6ae25490..154a8f56 100644 --- a/src/node/nodeDebug.ts +++ b/src/node/nodeDebug.ts @@ -462,26 +462,28 @@ export class NodeDebugSession extends LoggingDebugSession { return; } + let description: string | undefined; + // in order to identify rejects extract source at current location - if (this._skipRejects && eventBody.sourceLineText && typeof eventBody.sourceColumn === 'number') { + if (eventBody.sourceLineText && typeof eventBody.sourceColumn === 'number') { let source = eventBody.sourceLineText.substr(eventBody.sourceColumn); - // if this exception originates from a 'reject', skip it if 'All Exception' is not set. if (source.indexOf('reject(') === 0) { - if (!this._catchRejects) { + if (this._skipRejects && !this._catchRejects) { this._node.command('continue'); return; } - /* - if (eventBody.exception.text === 'undefined') { - eventBody.exception.text = 'reject'; + description = localize('exception.rejected.promise', "Rejected Promise"); + if (eventBody.exception.text) { + eventBody.exception.text = localize('exception.rejected.promise.text', "Rejected Promise ({0})", eventBody.exception.text); + } else { + eventBody.exception.text = localize('exception.rejected.promise.text', "Rejected Promise"); } - */ } } // send event this._exception = eventBody; - this._sendStoppedEvent('exception', eventBody.exception.text); + this._sendStoppedEvent('exception', description, eventBody.exception.text); } /** @@ -559,7 +561,7 @@ export class NodeDebugSession extends LoggingDebugSession { this._sendStoppedEvent('breakpoint'); } - private _sendStoppedEvent(reason: ReasonType, exception_text?: string): void { + private _sendStoppedEvent(reason: ReasonType, description?: string, exception_text?: string): void { if (this._smartStepCount > 0) { this.log('ss', `_handleNodeBreakEvent: ${this._smartStepCount} steps skipped`); @@ -568,29 +570,32 @@ export class NodeDebugSession extends LoggingDebugSession { const e = new StoppedEvent(reason, NodeDebugSession.DUMMY_THREAD_ID, exception_text); - switch (reason) { - case 'step': - (e).body.description = localize('reason.description.step', "Paused on step"); - break; - case 'breakpoint': - (e).body.description = localize('reason.description.breakpoint', "Paused on breakpoint"); - break; - case 'exception': - (e).body.description = localize('reason.description.exception', "Paused on exception"); - break; - case 'pause': - (e).body.description = localize('reason.description.user_request', "Paused on user request"); - break; - case 'entry': - (e).body.description = localize('reason.description.entry', "Paused on entry"); - break; - case 'debugger_statement': - (e).body.description = localize('reason.description.debugger_statement', "Paused on debugger statement"); - break; - case 'frame_entry': - (e).body.description = localize('reason.description.restart', "Paused on frame entry"); - break; + if (!description) { + switch (reason) { + case 'step': + description = localize('reason.description.step', "Paused on step"); + break; + case 'breakpoint': + description = localize('reason.description.breakpoint', "Paused on breakpoint"); + break; + case 'exception': + description = localize('reason.description.exception', "Paused on exception"); + break; + case 'pause': + description = localize('reason.description.user_request', "Paused on user request"); + break; + case 'entry': + description = localize('reason.description.entry', "Paused on entry"); + break; + case 'debugger_statement': + description = localize('reason.description.debugger_statement', "Paused on debugger statement"); + break; + case 'frame_entry': + description = localize('reason.description.restart', "Paused on frame entry"); + break; + } } + (e).body.description = description; this.sendEvent(e); } @@ -3667,7 +3672,8 @@ export class NodeDebugSession extends LoggingDebugSession { // try to retrieve the stack trace return this._createProperties(undefined, exception, 'named').then(values => { if (values.length > 0 && values[0].name === 'stack') { - return values[0].value; + const stack = values[0].value; + return stack === 'undefined' ? undefined : stack; } return undefined; }).catch(_ => {