-
Notifications
You must be signed in to change notification settings - Fork 179
/
errorHandler.ts
54 lines (48 loc) · 1.8 KB
/
errorHandler.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import TelemetryReporter from '@vscode/extension-telemetry';
import * as vscode from 'vscode';
import { CloseAction, ErrorAction, ErrorHandler, Message } from 'vscode-languageclient';
export class ExtensionErrorHandler implements ErrorHandler {
constructor(private outputChannel: vscode.OutputChannel, private reporter: TelemetryReporter) {}
error(error: Error, message: Message | undefined, count: number | undefined) {
vscode.window.showErrorMessage(`Terraform LS connection error: (${count})\n${error.message}\n${message?.jsonrpc}`);
this.reporter.sendTelemetryException(error);
return ErrorAction.Continue;
}
closed() {
this.outputChannel.appendLine(
`Failure to start terraform-ls. Please check your configuration settings and reload this window`,
);
vscode.window
.showErrorMessage(
'Failure to start terraform-ls. Please check your configuration settings and reload this window',
{
detail: '',
modal: false,
},
{ title: 'Open Settings' },
{ title: 'Open Logs' },
{ title: 'More Info' },
)
.then(async (choice) => {
if (choice === undefined) {
return;
}
switch (choice.title) {
case 'Open Logs':
this.outputChannel.show();
break;
case 'Open Settings':
await vscode.commands.executeCommand('workbench.action.openSettings', '@ext:hashicorp.terraform');
break;
case 'More Info':
await vscode.commands.executeCommand(
'vscode.open',
vscode.Uri.parse('https://github.com/hashicorp/vscode-terraform#troubleshooting'),
);
break;
}
});
// Tell VS Code to stop attempting to start
return CloseAction.DoNotRestart;
}
}