mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Changing dacFxService and schemaCompareService to use shared logic for error handling (#22718)
* Move helper function to base class * Switching DacFxService over * Thenable -> Promise * Converting SchemaCompareService
This commit is contained in:
@@ -11,9 +11,9 @@ import * as contracts from '../contracts';
|
||||
import { AppContext } from '../appContext';
|
||||
import { ISqlOpsFeature, SqlOpsDataClient } from 'dataprotocol-client';
|
||||
import { ClientCapabilities } from 'vscode-languageclient';
|
||||
import { RequestType } from 'vscode-languageclient';
|
||||
import { BaseService } from '../baseService';
|
||||
|
||||
export class SqlProjectsService implements mssql.ISqlProjectsService {
|
||||
export class SqlProjectsService extends BaseService implements mssql.ISqlProjectsService {
|
||||
public static asFeature(context: AppContext): ISqlOpsFeature {
|
||||
return class extends SqlProjectsService {
|
||||
constructor(client: SqlOpsDataClient) {
|
||||
@@ -29,7 +29,8 @@ export class SqlProjectsService implements mssql.ISqlProjectsService {
|
||||
};
|
||||
}
|
||||
|
||||
private constructor(context: AppContext, protected readonly client: SqlOpsDataClient) {
|
||||
private constructor(context: AppContext, client: SqlOpsDataClient) {
|
||||
super(client);
|
||||
context.registerService(constants.SqlProjectsService, this);
|
||||
}
|
||||
|
||||
@@ -445,14 +446,4 @@ export class SqlProjectsService implements mssql.ISqlProjectsService {
|
||||
const params: contracts.MoveItemParams = { projectUri: projectUri, destinationPath: destinationPath, path: path };
|
||||
return await this.runWithErrorHandling(contracts.MoveNoneItemRequest.type, params);
|
||||
}
|
||||
|
||||
private async runWithErrorHandling<P, R, E, RO>(type: RequestType<P, R, E, RO>, params: P): Promise<R> {
|
||||
try {
|
||||
const result = await this.client.sendRequest(type, params);
|
||||
return result;
|
||||
} catch (e) {
|
||||
this.client.logFailedRequest(type, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user