Skip to content

Commit

Permalink
handle error when continuing
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jan 18, 2019
1 parent ba96f6c commit 15a3332
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ class GoDebugSession extends LoggingDebugSession {

private _variableHandles: Handles<DebugVariable>;
private breakpoints: Map<string, DebugBreakpoint[]>;
private skipStopEventOnce: boolean;
private skipStopEventOnce: boolean; // Editing breakpoints requires halting delve, skip sending Stop Event to VS Code in such cases
private threads: Set<number>;
private debugState: DebuggerState;
private delve: Delve;
Expand Down Expand Up @@ -760,10 +760,10 @@ class GoDebugSession extends LoggingDebugSession {
this.skipStopEventOnce = true;
this.delve.callPromise('Command', [{ name: 'halt' }]).then(() => {
return this.setBreakPoints(response, args).then(() => {
return this.continue();
}, err => {
logError(err);
return this.sendErrorResponse(response, 2009, 'Failed to continue delve after setting the breakpoint: "{e}"', { e: err.toString() });
return this.continue(true).then(null, err => {
logError(err);
this.sendErrorResponse(response, 2009, 'Failed to continue delve after halting it to set breakpoints: "{e}"', { e: err.toString() });
});
});
}, err => {
logError(err);
Expand Down Expand Up @@ -1109,27 +1109,39 @@ class GoDebugSession extends LoggingDebugSession {

private continueEpoch = 0;
private continueRequestRunning = false;
private continue(): void {
private continue(calledWhenSettingBreakpoint?: boolean): Thenable<void> {
this.continueEpoch++;
let closureEpoch = this.continueEpoch;
this.continueRequestRunning = true;
this.delve.call<DebuggerState | CommandOut>('Command', [{ name: 'continue' }], (err, out) => {

const callback = (out) => {
if (closureEpoch === this.continueEpoch) {
this.continueRequestRunning = false;
}
if (err) {
logError('Failed to continue - ' + err.toString());
}
const state = this.delve.isApiV1 ? <DebuggerState>out : (<CommandOut>out).State;
log('continue state', state);
this.debugState = state;
this.handleReenterDebug('breakpoint');
};

// If called when setting breakpoint internally, we want the error to bubble up.
if (calledWhenSettingBreakpoint) {
return this.delve.callPromise('Command', [{ name: 'continue' }]).then(callback);
}
return this.delve.callPromise('Command', [{ name: 'continue' }]).then(callback, err => {
if (closureEpoch === this.continueEpoch) {
this.continueRequestRunning = false;
}
if (err) {
logError('Failed to continue - ' + err.toString());
}
});
}

protected continueRequest(response: DebugProtocol.ContinueResponse): void {
log('ContinueRequest');
this.continue();
this.continue().then(() => {
this.handleReenterDebug('breakpoint');
});
this.sendResponse(response);
log('ContinueResponse');
}
Expand Down

0 comments on commit 15a3332

Please sign in to comment.