Fix uncaught exception for resolve classpath command (#64)
* Fix uncaught exception for resolve classpath command Signed-off-by: Jinbo Wang <jinbwan@microsoft.com> * Handle exception at the outer catch Signed-off-by: Jinbo Wang <jinbwan@microsoft.com> * log exception to telemetry Signed-off-by: Jinbo Wang <jinbwan@microsoft.com> * fix review comment
This commit is contained in:
parent
4ee1f1b95d
commit
154b345bbd
|
@ -9,6 +9,9 @@ import * as commands from "./commands";
|
||||||
const status: any = {};
|
const status: any = {};
|
||||||
|
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
|
// The reporter will be initialized by the later telemetry handler.
|
||||||
|
let reporter: TelemetryReporter = null;
|
||||||
|
|
||||||
vscode.commands.registerCommand(commands.JAVA_START_DEBUGSESSION, async (config) => {
|
vscode.commands.registerCommand(commands.JAVA_START_DEBUGSESSION, async (config) => {
|
||||||
|
|
||||||
if (!status.debugging) {
|
if (!status.debugging) {
|
||||||
|
@ -19,7 +22,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||||
const level = await configLogLevel(vscode.workspace.getConfiguration().get("java.debug.logLevel"));
|
const level = await configLogLevel(vscode.workspace.getConfiguration().get("java.debug.logLevel"));
|
||||||
console.log("setting log level to ", level);
|
console.log("setting log level to ", level);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// log a warning message and contiue, since logger failure should not block debug session
|
// log a warning message and continue, since logger failure should not block debug session
|
||||||
console.log("Cannot set log level to java debuggeer.")
|
console.log("Cannot set log level to java debuggeer.")
|
||||||
}
|
}
|
||||||
if (Object.keys(config).length === 0) { // No launch.json in current workspace.
|
if (Object.keys(config).length === 0) { // No launch.json in current workspace.
|
||||||
|
@ -63,7 +66,18 @@ export function activate(context: vscode.ExtensionContext) {
|
||||||
console.log("Cannot find a port for debugging session");
|
console.log("Cannot find a port for debugging session");
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
const errorMessage = (ex && ex.message) || ex;
|
||||||
|
vscode.window.showErrorMessage(errorMessage);
|
||||||
|
if (reporter) {
|
||||||
|
const exception = (ex && ex.data && ex.data.cause)
|
||||||
|
|| { stackTrace: [], detailMessage: String((ex && ex.message) || ex || "Unknown exception") };
|
||||||
|
const properties = {};
|
||||||
|
properties.detailMessage = exception.detailMessage;
|
||||||
|
if (Array.isArray(exception.stackTrace)) {
|
||||||
|
properties.stackTrace = JSON.stringify(exception.stackTrace);
|
||||||
|
}
|
||||||
|
reporter.sendTelemetryEvent("exception", properties);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
delete status.debugging;
|
delete status.debugging;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +93,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||||
aiKey: extensionPackage.aiKey,
|
aiKey: extensionPackage.aiKey,
|
||||||
};
|
};
|
||||||
if (packageInfo.aiKey) {
|
if (packageInfo.aiKey) {
|
||||||
const reporter = new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
|
reporter = new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
|
||||||
reporter.sendTelemetryEvent("activateExtension", {});
|
reporter.sendTelemetryEvent("activateExtension", {});
|
||||||
const measureKeys = ["duration"];
|
const measureKeys = ["duration"];
|
||||||
vscode.debug.onDidTerminateDebugSession(() => {
|
vscode.debug.onDidTerminateDebugSession(() => {
|
||||||
|
|
Loading…
Reference in New Issue