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:
Benjin Dubishar
2023-04-13 12:44:13 -07:00
committed by GitHub
parent 35e1d63871
commit 8202e1ec4e
5 changed files with 85 additions and 173 deletions

View File

@@ -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;
}
}
}