@@ -121,6 +121,7 @@ export function withProgress<R>(
121121export function commandRunner (
122122 commandId : string ,
123123 task : NoProgressTask ,
124+ outputLogger = extLogger ,
124125) : Disposable {
125126 return commands . registerCommand ( commandId , async ( ...args : any [ ] ) => {
126127 const startTime = Date . now ( ) ;
@@ -137,16 +138,19 @@ export function commandRunner(
137138 if ( e instanceof UserCancellationException ) {
138139 // User has cancelled this action manually
139140 if ( e . silent ) {
140- void extLogger . log ( errorMessage . fullMessage ) ;
141+ void outputLogger . log ( errorMessage . fullMessage ) ;
141142 } else {
142- void showAndLogWarningMessage ( errorMessage . fullMessage ) ;
143+ void showAndLogWarningMessage ( errorMessage . fullMessage , {
144+ outputLogger,
145+ } ) ;
143146 }
144147 } else {
145148 // Include the full stack in the error log only.
146149 const fullMessage = errorStack
147150 ? `${ errorMessage . fullMessage } \n${ errorStack } `
148151 : errorMessage . fullMessage ;
149152 void showAndLogExceptionWithTelemetry ( errorMessage , {
153+ outputLogger,
150154 fullMessage,
151155 extraTelemetryProperties : {
152156 command : commandId ,
@@ -177,49 +181,18 @@ export function commandRunnerWithProgress<R>(
177181 progressOptions : Partial < ProgressOptions > ,
178182 outputLogger = extLogger ,
179183) : Disposable {
180- return commands . registerCommand ( commandId , async ( ...args : any [ ] ) => {
181- const startTime = Date . now ( ) ;
182- let error : Error | undefined ;
183- const progressOptionsWithDefaults = {
184- location : ProgressLocation . Notification ,
185- ...progressOptions ,
186- } ;
187- try {
188- return await withProgress ( progressOptionsWithDefaults , task , ...args ) ;
189- } catch ( e ) {
190- error = asError ( e ) ;
191- const errorMessage = redactableError `${
192- getErrorMessage ( e ) || e
193- } (${ commandId } )`;
194- const errorStack = getErrorStack ( e ) ;
195- if ( e instanceof UserCancellationException ) {
196- // User has cancelled this action manually
197- if ( e . silent ) {
198- void outputLogger . log ( errorMessage . fullMessage ) ;
199- } else {
200- void showAndLogWarningMessage ( errorMessage . fullMessage , {
201- outputLogger,
202- } ) ;
203- }
204- } else {
205- // Include the full stack in the error log only.
206- const fullMessage = errorStack
207- ? `${ errorMessage . fullMessage } \n${ errorStack } `
208- : errorMessage . fullMessage ;
209- void showAndLogExceptionWithTelemetry ( errorMessage , {
210- outputLogger,
211- fullMessage,
212- extraTelemetryProperties : {
213- command : commandId ,
214- } ,
215- } ) ;
216- }
217- return undefined ;
218- } finally {
219- const executionTime = Date . now ( ) - startTime ;
220- telemetryListener ?. sendCommandUsage ( commandId , executionTime , error ) ;
221- }
222- } ) ;
184+ return commandRunner (
185+ commandId ,
186+ async ( ...args : any [ ] ) => {
187+ const progressOptionsWithDefaults = {
188+ location : ProgressLocation . Notification ,
189+ ...progressOptions ,
190+ } ;
191+
192+ return withProgress ( progressOptionsWithDefaults , task , ...args ) ;
193+ } ,
194+ outputLogger ,
195+ ) ;
223196}
224197
225198/**
0 commit comments