Skip to content

Commit 6c80f32

Browse files
committed
moved the error logging
1 parent 12879e5 commit 6c80f32

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

src/commands.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,7 @@ class SwitchBranchItem implements QuickPickItem {
7777
}
7878

7979
async run(repository: Repository): Promise<void> {
80-
try {
81-
await repository.switchBranch(this.ref);
82-
} catch (error) {
83-
if (/E195012/.test(error)) {
84-
window.showErrorMessage(
85-
"Path '.' does not share common version control ancestry with the requested switch location."
86-
);
87-
return;
88-
}
89-
90-
window.showErrorMessage("Unable to switch branch");
91-
}
80+
await repository.switchBranch(this.ref);
9281
}
9382
}
9483

src/repository.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
SourceControlInputBox,
99
Disposable,
1010
EventEmitter,
11-
Event
11+
Event,
12+
window
1213
} from "vscode";
1314
import { Resource } from "./resource";
1415
import { throttle, debounce } from "./decorators";
@@ -112,8 +113,12 @@ export class Repository {
112113
this.changes.hideWhenEmpty = true;
113114
this.notTracked.hideWhenEmpty = true;
114115

115-
this.disposables.push(toDisposable(() => clearInterval(this.branchesTimer)));
116-
setInterval(() => {this.updateBranches()}, 1000 * 60 * 5); // 5 minutes
116+
this.disposables.push(
117+
toDisposable(() => clearInterval(this.branchesTimer))
118+
);
119+
setInterval(() => {
120+
this.updateBranches();
121+
}, 1000 * 60 * 5); // 5 minutes
117122

118123
this.updateBranches();
119124
this.update();
@@ -209,10 +214,22 @@ export class Repository {
209214
async switchBranch(name: string) {
210215
this.isSwitchingBranch = true;
211216
this._onDidChangeRepository.fire();
212-
const response = await this.repository.switchBranch(name);
213-
this.isSwitchingBranch = false;
214-
this.updateBranches();
215-
this._onDidChangeRepository.fire();
216-
return response;
217+
218+
try {
219+
const response = await this.repository.switchBranch(name);
220+
} catch (error) {
221+
if (/E195012/.test(error)) {
222+
window.showErrorMessage(
223+
"Path '.' does not share common version control ancestry with the requested switch location."
224+
);
225+
return;
226+
}
227+
228+
window.showErrorMessage("Unable to switch branch");
229+
} finally {
230+
this.isSwitchingBranch = false;
231+
this.updateBranches();
232+
this._onDidChangeRepository.fire();
233+
}
217234
}
218235
}

0 commit comments

Comments
 (0)