mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Converting remaining services to use runWithErrorHandling() (#22720)
* Converting remaining services to use `runWithErrorHandling()` * Updating sqlops-dataprotocolclient to 1.3.3 * upgrading dataprotocol and swapping to that baseService * Adding async to make thenable -> promise conversion happy --------- Co-authored-by: Alan Ren <alanren@microsoft.com>
This commit is contained in:
@@ -3,18 +3,19 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { AppContext } from '../appContext';
|
||||
import { SqlOpsDataClient, ISqlOpsFeature } from 'dataprotocol-client';
|
||||
import { ClientCapabilities } from 'vscode-languageclient';
|
||||
import * as constants from '../constants';
|
||||
import * as contracts from '../contracts';
|
||||
|
||||
import { AppContext } from '../appContext';
|
||||
import { SqlOpsDataClient, ISqlOpsFeature, BaseService } from 'dataprotocol-client';
|
||||
import { ClientCapabilities } from 'vscode-languageclient';
|
||||
|
||||
export interface INotebookConvertService {
|
||||
convertNotebookToSql(content: string): Promise<contracts.ConvertNotebookToSqlResult | undefined>;
|
||||
convertSqlToNotebook(content: string): Promise<contracts.ConvertSqlToNotebookResult | undefined>;
|
||||
}
|
||||
|
||||
export class NotebookConvertService implements INotebookConvertService {
|
||||
export class NotebookConvertService extends BaseService implements INotebookConvertService {
|
||||
public static asFeature(context: AppContext): ISqlOpsFeature {
|
||||
return class extends NotebookConvertService {
|
||||
constructor(client: SqlOpsDataClient) {
|
||||
@@ -29,30 +30,17 @@ export class NotebookConvertService implements INotebookConvertService {
|
||||
};
|
||||
}
|
||||
|
||||
private constructor(context: AppContext, protected readonly client: SqlOpsDataClient) {
|
||||
private constructor(context: AppContext, client: SqlOpsDataClient) {
|
||||
super(client);
|
||||
context.registerService(constants.NotebookConvertService, this);
|
||||
}
|
||||
|
||||
async convertNotebookToSql(content: string): Promise<contracts.ConvertNotebookToSqlResult | undefined> {
|
||||
let params: contracts.ConvertNotebookToSqlParams = { content: content };
|
||||
try {
|
||||
return this.client.sendRequest(contracts.ConvertNotebookToSqlRequest.type, params);
|
||||
}
|
||||
catch (e) {
|
||||
this.client.logFailedRequest(contracts.ConvertNotebookToSqlRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return this.runWithErrorHandling(contracts.ConvertNotebookToSqlRequest.type, params);
|
||||
}
|
||||
async convertSqlToNotebook(content: string): Promise<contracts.ConvertSqlToNotebookResult | undefined> {
|
||||
let params: contracts.ConvertSqlToNotebookParams = { clientUri: content };
|
||||
try {
|
||||
return this.client.sendRequest(contracts.ConvertSqlToNotebookRequest.type, params);
|
||||
}
|
||||
catch (e) {
|
||||
this.client.logFailedRequest(contracts.ConvertSqlToNotebookRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return this.runWithErrorHandling(contracts.ConvertSqlToNotebookRequest.type, params);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user