Skip to content

Commit 35a496c

Browse files
committed
Fixes incorrect error handling
1 parent de6d963 commit 35a496c

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

src/env/node/git/git.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ export class Git {
896896
);
897897
return result.stdout;
898898
} catch (ex) {
899-
if (ex instanceof RunError && ex.stdout) {
899+
if (ex instanceof GitError && ex.stdout) {
900900
return ex.stdout;
901901
}
902902

@@ -1475,9 +1475,9 @@ export class Git {
14751475
}
14761476
} catch (ex) {
14771477
if (
1478-
ex instanceof RunError &&
1479-
ex.stdout.includes('Saved working directory and index state') &&
1480-
ex.stderr.includes('Cannot remove worktree changes')
1478+
ex instanceof GitError &&
1479+
ex.stdout?.includes('Saved working directory and index state') &&
1480+
ex.stderr?.includes('Cannot remove worktree changes')
14811481
) {
14821482
throw new StashPushError(StashPushErrorReason.ConflictingStagedAndUnstagedLines);
14831483
}

src/env/node/git/sub-providers/branches.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ import { normalizePath } from '../../../../system/path';
3939
import { getSettledValue } from '../../../../system/promise';
4040
import { maybeStopWatch } from '../../../../system/stopwatch';
4141
import type { Git } from '../git';
42-
import { GitErrors, gitLogDefaultConfigs } from '../git';
42+
import { GitError, GitErrors, gitLogDefaultConfigs } from '../git';
4343
import type { LocalGitProvider } from '../localGitProvider';
44-
import { RunError } from '../shell.errors';
4544

4645
const emptyPagedResult: PagedResult<any> = Object.freeze({ values: [] });
4746

@@ -612,7 +611,7 @@ export class BranchesGitSubProvider implements GitBranchesSubProvider {
612611
scope,
613612
`Unable to merge '${branch}' and '${targetBranch}' as they have no common ancestor`,
614613
);
615-
} else if (ex instanceof RunError) {
614+
} else if (ex instanceof GitError) {
616615
data = ex.stdout;
617616
} else {
618617
Logger.error(ex, scope);

src/env/node/git/sub-providers/stash.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import { log } from '../../../../system/decorators/log';
2222
import { join, map, min, skip } from '../../../../system/iterable';
2323
import { getSettledValue } from '../../../../system/promise';
2424
import type { Git } from '../git';
25-
import { maxGitCliLength } from '../git';
26-
import { RunError } from '../shell.errors';
25+
import { GitError, maxGitCliLength } from '../git';
2726
import { createCommitFileset } from './commits';
2827

2928
const stashSummaryRegex =
@@ -54,9 +53,9 @@ export class StashGitSubProvider implements GitStashSubProvider {
5453

5554
if (
5655
(msg.includes('Auto-merging') && msg.includes('CONFLICT')) ||
57-
(ex instanceof RunError &&
58-
((ex.stdout.includes('Auto-merging') && ex.stdout.includes('CONFLICT')) ||
59-
ex.stdout.includes('needs merge')))
56+
(ex instanceof GitError &&
57+
((ex.stdout?.includes('Auto-merging') && ex.stdout.includes('CONFLICT')) ||
58+
ex.stdout?.includes('needs merge')))
6059
) {
6160
void window.showInformationMessage('Stash applied with conflicts');
6261

0 commit comments

Comments
 (0)