Skip to content

Commit

Permalink
moved the error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnstonCode committed Dec 4, 2017
1 parent 12879e5 commit 6c80f32
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
13 changes: 1 addition & 12 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,7 @@ class SwitchBranchItem implements QuickPickItem {
}

async run(repository: Repository): Promise<void> {
try {
await repository.switchBranch(this.ref);
} catch (error) {
if (/E195012/.test(error)) {
window.showErrorMessage(
"Path '.' does not share common version control ancestry with the requested switch location."
);
return;
}

window.showErrorMessage("Unable to switch branch");
}
await repository.switchBranch(this.ref);
}
}

Expand Down
33 changes: 25 additions & 8 deletions src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
SourceControlInputBox,
Disposable,
EventEmitter,
Event
Event,
window
} from "vscode";
import { Resource } from "./resource";
import { throttle, debounce } from "./decorators";
Expand Down Expand Up @@ -112,8 +113,12 @@ export class Repository {
this.changes.hideWhenEmpty = true;
this.notTracked.hideWhenEmpty = true;

this.disposables.push(toDisposable(() => clearInterval(this.branchesTimer)));
setInterval(() => {this.updateBranches()}, 1000 * 60 * 5); // 5 minutes
this.disposables.push(
toDisposable(() => clearInterval(this.branchesTimer))
);
setInterval(() => {
this.updateBranches();
}, 1000 * 60 * 5); // 5 minutes

this.updateBranches();
this.update();
Expand Down Expand Up @@ -209,10 +214,22 @@ export class Repository {
async switchBranch(name: string) {
this.isSwitchingBranch = true;
this._onDidChangeRepository.fire();
const response = await this.repository.switchBranch(name);
this.isSwitchingBranch = false;
this.updateBranches();
this._onDidChangeRepository.fire();
return response;

try {
const response = await this.repository.switchBranch(name);
} catch (error) {
if (/E195012/.test(error)) {
window.showErrorMessage(
"Path '.' does not share common version control ancestry with the requested switch location."
);
return;
}

window.showErrorMessage("Unable to switch branch");
} finally {
this.isSwitchingBranch = false;
this.updateBranches();
this._onDidChangeRepository.fire();
}
}
}

0 comments on commit 6c80f32

Please sign in to comment.