Skip to content

Commit b5285f0

Browse files
author
ole1986
committed
use IApplicationShell to show failures on actionRef and actionCommit requests
1 parent 8b9b477 commit b5285f0

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

browser/src/actions/results.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export const actionCommit = (logEntry: LogEntry, name: string = '', value: strin
4545
break;
4646
}
4747
dispatch(updateCommitInList(result.data as LogEntry));
48+
}).catch(ex => {
49+
dispatch(updateCommitInList(logEntry));
4850
});
4951
};
5052
};
@@ -63,6 +65,8 @@ export const actionRef = (logEntry: LogEntry, ref: Ref, name: string = '') => {
6365

6466
dispatch(getBranches());
6567
dispatch(updateCommitInList(logEntry));
68+
}).catch(ex => {
69+
dispatch(updateCommitInList(logEntry));
6670
});
6771
};
6872
};

src/adapter/repository/git.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ export class Git implements IGitService {
304304
}
305305

306306
public async createBranch(branchName: string, hash: string): Promise<void> {
307-
await this.repo.createBranch(branchName, false, hash);
307+
try {
308+
await this.repo.createBranch(branchName, false, hash);
309+
} catch (ex) {
310+
throw ex.stderr;
311+
}
308312
}
309313

310314
public async createTag(tagName: string, hash: string): Promise<any> {
@@ -316,7 +320,11 @@ export class Git implements IGitService {
316320
}
317321

318322
public async removeBranch(branchName: string) {
319-
await this.repo.deleteBranch(branchName);
323+
try {
324+
await this.repo.deleteBranch(branchName);
325+
} catch (ex) {
326+
throw ex.stderr;
327+
}
320328
}
321329

322330
public async removeRemoteBranch(remoteBranchName: string) {

src/server/apiController.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@ import { CommitDetails, FileCommitDetails } from '../common/types';
99
import { IServiceContainer } from '../ioc/types';
1010
import { Avatar, CommittedFile, IGitService, IGitServiceFactory, LogEntries, LogEntriesResponse, LogEntry, Ref, RefType } from '../types';
1111
import { IApiRouteHandler } from './types';
12+
import { IApplicationShell } from '../application/types';
1213

1314
// tslint:disable-next-line:no-require-imports no-var-requires
1415

1516
@injectable()
1617
export class ApiController implements IApiRouteHandler {
1718
private readonly commitViewer: IGitCommitViewDetailsCommandHandler;
19+
private readonly applicationShell: IApplicationShell;
1820
constructor(private app: Express,
1921
private gitServiceFactory: IGitServiceFactory,
2022
private serviceContainer: IServiceContainer,
2123
private commandManager: ICommandManager) {
2224

2325
this.commitViewer = this.serviceContainer.get<IGitCommitViewDetailsCommandHandler>(IGitCommitViewDetailsCommandHandler);
26+
this.applicationShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
2427

2528
this.app.get('/log', this.handleRequest(this.getLogEntries.bind(this)));
2629
this.app.get('/branches', this.handleRequest(this.getBranches.bind(this)));
@@ -167,6 +170,7 @@ export class ApiController implements IApiRouteHandler {
167170
}
168171
response.status(200).send('');
169172
} catch (err) {
173+
this.applicationShell.showErrorMessage(err);
170174
response.status(500).send(err);
171175
}
172176
}
@@ -204,6 +208,7 @@ export class ApiController implements IApiRouteHandler {
204208
}
205209
response.status(200).send(logEntry);
206210
} catch(err) {
211+
this.applicationShell.showErrorMessage(err);
207212
response.status(500).send(err);
208213
}
209214
}

0 commit comments

Comments
 (0)