Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

When delve fails, stop the debug sessions #774

Merged
merged 2 commits into from
Feb 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class Delve {
connection: Promise<RPCConnection>;
onstdout: (str: string) => void;
onstderr: (str: string) => void;
onclose: () => void;

constructor(mode: string, remotePath: string, port: number, host: string, program: string, args: string[], showLog: boolean, cwd: string, env: { [key: string]: string }, buildFlags: string, init: string) {
this.program = program;
Expand Down Expand Up @@ -268,9 +269,10 @@ class Delve {
connectClient(port, host);
}
});
this.debugProcess.on('close', function(code) {
this.debugProcess.on('close', (code) => {
// TODO: Report `dlv` crash to user.
logError('Process exiting with code: ' + code);
if (code !== 0 && this.onclose) { this.onclose(); }
});
this.debugProcess.on('error', function(err) {
reject(err);
Expand Down Expand Up @@ -388,6 +390,10 @@ class GoDebugSession extends DebugSession {
this.delve.onstderr = (str: string) => {
this.sendEvent(new OutputEvent(str, 'stderr'));
};
this.delve.onclose = () => {
this.sendErrorResponse(response, 3000, 'Failed to continue: Check the debug console for details.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 'failed to continue'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cos it matches with the other message for when the delve.connection fails?

verbose('Delve is closed');
};

this.delve.connection.then(() => {
this.sendEvent(new InitializedEvent());
Expand Down