Skip to content

Commit

Permalink
introduce debug.onTaskErrors
Browse files Browse the repository at this point in the history
fixes #68084
  • Loading branch information
isidorn committed Sep 5, 2019
1 parent d591cb7 commit 5ebf2ab
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/debug/browser/debug.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ configurationRegistry.registerConfiguration({
type: 'boolean',
description: nls.localize('debug.focusWindowOnBreak', "Controls whether the workbench window should be focused when the debugger breaks."),
default: true
},
'debug.onTaskErrors': {
enum: ['debugAnyway', 'showErrors', 'prompt'],
description: nls.localize('debug.onTaskErrors', "Controls what to do when errors are encountered after running a preLaunchTask."),
default: 'prompt'
}
}
});
Expand Down
34 changes: 26 additions & 8 deletions src/vs/workbench/contrib/debug/browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { parse, getFirstFrame } from 'vs/base/common/console';
import { TaskEvent, TaskEventKind, TaskIdentifier } from 'vs/workbench/contrib/tasks/common/tasks';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IAction, Action } from 'vs/base/common/actions';
import { IAction } from 'vs/base/common/actions';
import { deepClone, equals } from 'vs/base/common/objects';
import { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
Expand Down Expand Up @@ -686,13 +686,18 @@ export class DebugService implements IDebugService {

private runTaskAndCheckErrors(root: IWorkspaceFolder | undefined, taskId: string | TaskIdentifier | undefined): Promise<TaskRunResult> {

const debugAnywayAction = new Action('debug.debugAnyway', nls.localize('debugAnyway', "Debug Anyway"), undefined, true, () => Promise.resolve(TaskRunResult.Success));
return this.runTask(root, taskId).then((taskSummary: ITaskSummary) => {

const errorCount = taskId ? this.markerService.getStatistics().errors : 0;
const successExitCode = taskSummary && taskSummary.exitCode === 0;
const failureExitCode = taskSummary && taskSummary.exitCode !== undefined && taskSummary.exitCode !== 0;
if (successExitCode || (errorCount === 0 && !failureExitCode)) {
return <any>TaskRunResult.Success;
const onTaskErrors = this.configurationService.getValue<IDebugConfiguration>('debug').onTaskErrors;
if (successExitCode || onTaskErrors === 'debugAnyway' || (errorCount === 0 && !failureExitCode)) {
return TaskRunResult.Success;
}
if (onTaskErrors === 'showErrors') {
this.panelService.openPanel(Constants.MARKERS_PANEL_ID);
return Promise.resolve(TaskRunResult.Failure);
}

const taskLabel = typeof taskId === 'string' ? taskId : taskId ? taskId.name : '';
Expand All @@ -702,14 +707,27 @@ export class DebugService implements IDebugService {
? nls.localize('preLaunchTaskError', "Error exists after running preLaunchTask '{0}'.", taskLabel)
: nls.localize('preLaunchTaskExitCode', "The preLaunchTask '{0}' terminated with exit code {1}.", taskLabel, taskSummary.exitCode);

const showErrorsAction = new Action('debug.showErrors', nls.localize('showErrors', "Show Errors"), undefined, true, () => {
return this.dialogService.confirm({
checkbox: {
label: nls.localize('remember', "Remember my choice in settings"),
},
message,
type: 'warning',
primaryButton: nls.localize('debugAnyway', "Debug Anyway"),
secondaryButton: nls.localize('showErrors', "Show Errors"),
}).then(result => {
if (result.checkboxChecked) {
this.configurationService.updateValue('debug.onTaskErrors', result.confirmed ? 'debugAnyway' : 'showErrors');
}
if (result.confirmed) {
return TaskRunResult.Success;
}

this.panelService.openPanel(Constants.MARKERS_PANEL_ID);
return Promise.resolve(TaskRunResult.Failure);
});

return this.showError(message, [debugAnywayAction, showErrorsAction]);
}, (err: TaskError) => {
return this.showError(err.message, [debugAnywayAction, this.taskService.configureAction()]);
return this.showError(err.message, [this.taskService.configureAction()]);
});
}

Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ export interface IDebugConfiguration {
wordWrap: boolean;
};
focusWindowOnBreak: boolean;
onTaskErrors: 'debugAnyway' | 'showErrors' | 'prompt';
}

export interface IGlobalConfig {
Expand Down

0 comments on commit 5ebf2ab

Please sign in to comment.