From fc6e8fdac2e6a4ffce304ec7752bc028ddae289f Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 5 Feb 2020 12:40:26 +0100 Subject: [PATCH] fixes #89059 --- .../contrib/debug/browser/debugSession.ts | 3 +-- .../contrib/debug/browser/rawDebugSession.ts | 16 +++++++++++----- .../workbench/contrib/debug/common/debugUtils.ts | 2 +- .../contrib/debug/test/browser/repl.test.ts | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/debugSession.ts b/src/vs/workbench/contrib/debug/browser/debugSession.ts index a6c75b4d2ae..11c7ef8329c 100644 --- a/src/vs/workbench/contrib/debug/browser/debugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/debugSession.ts @@ -190,7 +190,7 @@ export class DebugSession implements IDebugSession { try { const customTelemetryService = await dbgr.getCustomTelemetryService(); const debugAdapter = await dbgr.createDebugAdapter(this); - this.raw = new RawDebugSession(debugAdapter, dbgr, this.telemetryService, customTelemetryService, this.extensionHostDebugService, this.openerService); + this.raw = new RawDebugSession(debugAdapter, dbgr, this.telemetryService, customTelemetryService, this.extensionHostDebugService, this.openerService, this.notificationService); await this.raw.start(); this.registerListeners(); @@ -693,7 +693,6 @@ export class DebugSession implements IDebugSession { await this.raw.configurationDone(); } catch (e) { // Disconnect the debug session on configuration done error #10596 - this.notificationService.error(e); if (this.raw) { this.raw.disconnect(); } diff --git a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts index f7bbb068852..f751bebda62 100644 --- a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts @@ -19,6 +19,7 @@ import { env as processEnv } from 'vs/base/common/process'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { CancellationToken } from 'vs/base/common/cancellation'; +import { INotificationService } from 'vs/platform/notification/common/notification'; /** * This interface represents a single command line argument split into a "prefix" and a "path" half. @@ -79,7 +80,8 @@ export class RawDebugSession implements IDisposable { private readonly telemetryService: ITelemetryService, public readonly customTelemetryService: ITelemetryService | undefined, private readonly extensionHostDebugService: IExtensionHostDebugService, - private readonly openerService: IOpenerService + private readonly openerService: IOpenerService, + private readonly notificationService: INotificationService ) { this.debugAdapter = debugAdapter; this._capabilities = Object.create(null); @@ -632,8 +634,8 @@ export class RawDebugSession implements IDisposable { return errors.canceled(); } - const error = errorResponse && errorResponse.body ? errorResponse.body.error : null; - const errorMessage = errorResponse ? errorResponse.message || '' : ''; + const error: DebugProtocol.Message | undefined = errorResponse?.body?.error; + const errorMessage = errorResponse?.message || ''; if (error && error.sendTelemetry) { const telemetryMessage = error ? formatPII(error.format, true, error.variables) : errorMessage; @@ -641,15 +643,19 @@ export class RawDebugSession implements IDisposable { } const userMessage = error ? formatPII(error.format, false, error.variables) : errorMessage; - if (error && error.url) { + const url = error?.url; + if (error && url) { const label = error.urlLabel ? error.urlLabel : nls.localize('moreInfo', "More Info"); return createErrorWithActions(userMessage, { actions: [new Action('debug.moreInfo', label, undefined, true, () => { - this.openerService.open(URI.parse(error.url)); + this.openerService.open(URI.parse(url)); return Promise.resolve(null); })] }); } + if (error && error.format && error.showUser) { + this.notificationService.error(error.format); + } return new Error(userMessage); } diff --git a/src/vs/workbench/contrib/debug/common/debugUtils.ts b/src/vs/workbench/contrib/debug/common/debugUtils.ts index 0b287f5a12c..5f7e0b2b8ae 100644 --- a/src/vs/workbench/contrib/debug/common/debugUtils.ts +++ b/src/vs/workbench/contrib/debug/common/debugUtils.ts @@ -11,7 +11,7 @@ import { deepClone } from 'vs/base/common/objects'; const _formatPIIRegexp = /{([^}]+)}/g; -export function formatPII(value: string, excludePII: boolean, args: { [key: string]: string }): string { +export function formatPII(value: string, excludePII: boolean, args: { [key: string]: string } | undefined): string { return value.replace(_formatPIIRegexp, function (match, group) { if (excludePII && group.length > 0 && group[0] !== '_') { return match; diff --git a/src/vs/workbench/contrib/debug/test/browser/repl.test.ts b/src/vs/workbench/contrib/debug/test/browser/repl.test.ts index c155eca7669..297496be064 100644 --- a/src/vs/workbench/contrib/debug/test/browser/repl.test.ts +++ b/src/vs/workbench/contrib/debug/test/browser/repl.test.ts @@ -135,7 +135,7 @@ suite('Debug - REPL', () => { model.addSession(session); const adapter = new MockDebugAdapter(); - const raw = new RawDebugSession(adapter, undefined!, undefined!, undefined!, undefined!, undefined!); + const raw = new RawDebugSession(adapter, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!); session.initializeForTest(raw); await session.addReplExpression(undefined, 'before.1'); -- GitLab