@@ -6,7 +6,10 @@ import {
66 Disposable ,
77 ProgressLocation ,
88} from "vscode" ;
9- import { showAndLogErrorMessage , showAndLogWarningMessage } from "./helpers" ;
9+ import {
10+ showAndLogExceptionWithTelemetry ,
11+ showAndLogWarningMessage ,
12+ } from "./helpers" ;
1013import { extLogger } from "./common" ;
1114import { asError , getErrorMessage , getErrorStack } from "./pure/helpers-pure" ;
1215import { telemetryListener } from "./telemetry" ;
@@ -125,23 +128,27 @@ export function commandRunner(
125128 try {
126129 return await task ( ...args ) ;
127130 } catch ( e ) {
128- const errorMessage = `${ getErrorMessage ( e ) || e } (${ commandId } )` ;
131+ const notificationMessage = `${ getErrorMessage ( e ) || e } (${ commandId } )` ;
129132 error = asError ( e ) ;
130133 const errorStack = getErrorStack ( e ) ;
131134 if ( e instanceof UserCancellationException ) {
132135 // User has cancelled this action manually
133136 if ( e . silent ) {
134- void extLogger . log ( errorMessage ) ;
137+ void extLogger . log ( notificationMessage ) ;
135138 } else {
136- void showAndLogWarningMessage ( errorMessage ) ;
139+ void showAndLogWarningMessage ( notificationMessage ) ;
137140 }
138141 } else {
139142 // Include the full stack in the error log only.
140143 const fullMessage = errorStack
141- ? `${ errorMessage } \n${ errorStack } `
142- : errorMessage ;
143- void showAndLogErrorMessage ( errorMessage , {
144+ ? `${ notificationMessage } \n${ errorStack } `
145+ : notificationMessage ;
146+ void showAndLogExceptionWithTelemetry ( error , "command_failed" , {
147+ notificationMessage,
144148 fullMessage,
149+ extraTelemetryProperties : {
150+ command : commandId ,
151+ } ,
145152 } ) ;
146153 }
147154 return undefined ;
@@ -178,24 +185,28 @@ export function commandRunnerWithProgress<R>(
178185 try {
179186 return await withProgress ( progressOptionsWithDefaults , task , ...args ) ;
180187 } catch ( e ) {
181- const errorMessage = `${ getErrorMessage ( e ) || e } (${ commandId } )` ;
188+ const notificationMessage = `${ getErrorMessage ( e ) || e } (${ commandId } )` ;
182189 error = asError ( e ) ;
183190 const errorStack = getErrorStack ( e ) ;
184191 if ( e instanceof UserCancellationException ) {
185192 // User has cancelled this action manually
186193 if ( e . silent ) {
187- void outputLogger . log ( errorMessage ) ;
194+ void outputLogger . log ( notificationMessage ) ;
188195 } else {
189- void showAndLogWarningMessage ( errorMessage , { outputLogger } ) ;
196+ void showAndLogWarningMessage ( notificationMessage , { outputLogger } ) ;
190197 }
191198 } else {
192199 // Include the full stack in the error log only.
193200 const fullMessage = errorStack
194- ? `${ errorMessage } \n${ errorStack } `
195- : errorMessage ;
196- void showAndLogErrorMessage ( errorMessage , {
201+ ? `${ notificationMessage } \n${ errorStack } `
202+ : notificationMessage ;
203+ void showAndLogExceptionWithTelemetry ( error , "command_failed" , {
197204 outputLogger,
205+ notificationMessage,
198206 fullMessage,
207+ extraTelemetryProperties : {
208+ command : commandId ,
209+ } ,
199210 } ) ;
200211 }
201212 return undefined ;
0 commit comments