@@ -9,6 +9,9 @@ import * as commands from "./commands";
99const status : any = { } ;
1010
1111export function activate ( context : vscode . ExtensionContext ) {
12+ // The reporter will be initialized by the later telemetry handler.
13+ let reporter : TelemetryReporter = null ;
14+
1215 vscode . commands . registerCommand ( commands . JAVA_START_DEBUGSESSION , async ( config ) => {
1316
1417 if ( ! status . debugging ) {
@@ -19,7 +22,7 @@ export function activate(context: vscode.ExtensionContext) {
1922 const level = await configLogLevel ( vscode . workspace . getConfiguration ( ) . get ( "java.debug.logLevel" ) ) ;
2023 console . log ( "setting log level to " , level ) ;
2124 } catch ( err ) {
22- // log a warning message and contiue , since logger failure should not block debug session
25+ // log a warning message and continue , since logger failure should not block debug session
2326 console . log ( "Cannot set log level to java debuggeer." )
2427 }
2528 if ( Object . keys ( config ) . length === 0 ) { // No launch.json in current workspace.
@@ -63,7 +66,18 @@ export function activate(context: vscode.ExtensionContext) {
6366 console . log ( "Cannot find a port for debugging session" ) ;
6467 }
6568 } catch ( ex ) {
66-
69+ const errorMessage = ( ex && ex . message ) || ex ;
70+ vscode . window . showErrorMessage ( errorMessage ) ;
71+ if ( reporter ) {
72+ const exception = ( ex && ex . data && ex . data . cause )
73+ || { stackTrace : [ ] , detailMessage : String ( ( ex && ex . message ) || ex || "Unknown exception" ) } ;
74+ const properties = { } ;
75+ properties . detailMessage = exception . detailMessage ;
76+ if ( Array . isArray ( exception . stackTrace ) ) {
77+ properties . stackTrace = JSON . stringify ( exception . stackTrace ) ;
78+ }
79+ reporter . sendTelemetryEvent ( "exception" , properties ) ;
80+ }
6781 } finally {
6882 delete status . debugging ;
6983 }
@@ -79,7 +93,7 @@ export function activate(context: vscode.ExtensionContext) {
7993 aiKey : extensionPackage . aiKey ,
8094 } ;
8195 if ( packageInfo . aiKey ) {
82- const reporter = new TelemetryReporter ( packageInfo . name , packageInfo . version , packageInfo . aiKey ) ;
96+ reporter = new TelemetryReporter ( packageInfo . name , packageInfo . version , packageInfo . aiKey ) ;
8397 reporter . sendTelemetryEvent ( "activateExtension" , { } ) ;
8498 const measureKeys = [ "duration" ] ;
8599 vscode . debug . onDidTerminateDebugSession ( ( ) => {
0 commit comments