@@ -27,6 +27,7 @@ import { CONTEXT_COMMANDS } from './components/FileList';
27
27
import { MergeBranchDialog } from './components/MergeBranchDialog' ;
28
28
import { AUTH_ERROR_MESSAGES , requestAPI } from './git' ;
29
29
import { logger } from './logger' ;
30
+ import { CancelledError } from './cancelledError' ;
30
31
import { getDiffProvider , GitExtension } from './model' ;
31
32
import {
32
33
addIcon ,
@@ -342,16 +343,24 @@ export function addCommands(
342
343
level : Level . SUCCESS ,
343
344
details
344
345
} ) ;
345
- } catch ( error ) {
346
- console . error (
347
- trans . __ ( 'Encountered an error when pushing changes. Error: ' ) ,
348
- error
349
- ) ;
350
- logger . log ( {
351
- message : trans . __ ( 'Failed to push' ) ,
352
- level : Level . ERROR ,
353
- error : error as Error
354
- } ) ;
346
+ } catch ( error : any ) {
347
+ if ( error . name !== 'CancelledError' ) {
348
+ console . error (
349
+ trans . __ ( 'Encountered an error when pushing changes. Error: ' ) ,
350
+ error
351
+ ) ;
352
+ logger . log ( {
353
+ message : trans . __ ( 'Failed to push' ) ,
354
+ level : Level . ERROR ,
355
+ error : error as Error
356
+ } ) ;
357
+ } else {
358
+ return logger . log ( {
359
+ //Empty logger to supress the message
360
+ message : '' ,
361
+ level : Level . INFO
362
+ } ) ;
363
+ }
355
364
}
356
365
}
357
366
} ) ;
@@ -388,41 +397,49 @@ export function addCommands(
388
397
level : Level . SUCCESS ,
389
398
details
390
399
} ) ;
391
- } catch ( error ) {
392
- console . error (
393
- 'Encountered an error when pulling changes. Error: ' ,
394
- error
395
- ) ;
400
+ } catch ( error : any ) {
401
+ if ( error . name !== 'CancelledError' ) {
402
+ console . error (
403
+ 'Encountered an error when pulling changes. Error: ' ,
404
+ error
405
+ ) ;
396
406
397
- const errorMsg =
398
- typeof error === 'string' ? error : ( error as Error ) . message ;
407
+ const errorMsg =
408
+ typeof error === 'string' ? error : ( error as Error ) . message ;
399
409
400
- // Discard changes then retry pull
401
- if (
402
- errorMsg
403
- . toLowerCase ( )
404
- . includes (
405
- 'your local changes to the following files would be overwritten by merge'
406
- )
407
- ) {
408
- await commands . execute ( CommandIDs . gitPull , {
409
- force : true ,
410
- fallback : true
411
- } ) ;
412
- } else {
413
- if ( ( error as any ) . cancelled ) {
414
- // Empty message to hide alert
415
- logger . log ( {
416
- message : '' ,
417
- level : Level . INFO
410
+ // Discard changes then retry pull
411
+ if (
412
+ errorMsg
413
+ . toLowerCase ( )
414
+ . includes (
415
+ 'your local changes to the following files would be overwritten by merge'
416
+ )
417
+ ) {
418
+ await commands . execute ( CommandIDs . gitPull , {
419
+ force : true ,
420
+ fallback : true
418
421
} ) ;
419
422
} else {
420
- logger . log ( {
421
- message : trans . __ ( 'Failed to pull' ) ,
422
- level : Level . ERROR ,
423
- error
424
- } ) ;
423
+ if ( ( error as any ) . cancelled ) {
424
+ // Empty message to hide alert
425
+ logger . log ( {
426
+ message : '' ,
427
+ level : Level . INFO
428
+ } ) ;
429
+ } else {
430
+ logger . log ( {
431
+ message : trans . __ ( 'Failed to pull' ) ,
432
+ level : Level . ERROR ,
433
+ error
434
+ } ) ;
435
+ }
425
436
}
437
+ } else {
438
+ return logger . log ( {
439
+ //Empty logger to supress the message
440
+ message : '' ,
441
+ level : Level . INFO
442
+ } ) ;
426
443
}
427
444
}
428
445
}
@@ -1577,6 +1594,8 @@ export async function showGitOperationDialog<T>(
1577
1594
credentials . value ,
1578
1595
true
1579
1596
) ;
1597
+ } else {
1598
+ throw new CancelledError ( ) ;
1580
1599
}
1581
1600
}
1582
1601
// Throw the error if it cannot be handled or
0 commit comments