How to use the vscode-azureextensionui.callWithTelemetryAndErrorHandlingSync function in vscode-azureextensionui

To help you get started, we’ve selected a few vscode-azureextensionui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / vscode-azurearmtools / src / languageclient / WrappedErrorHandler.ts View on Github external
public closed(): CloseAction {
        // Use our shared error handling code to notification telemetry and user of the error
        // in a standard way
        callWithTelemetryAndErrorHandlingSync(languageServerErrorTelemId, (context: IActionContext) => {
            context.telemetry.measurements.secondsSinceStart = (Date.now() - this._serverStartTime) / 1000;

            throw new Error(`The connection to the ${languageServerName} got closed.`);
        });

        return this._handler.closed();
    }
}
github microsoft / vscode-azurearmtools / src / languageclient / WrappedErrorHandler.ts View on Github external
public error(error: Error, message: Message, count: number): ErrorAction {
        // Use our shared error handling code to notification telemetry and user of the error
        // in a standard way
        callWithTelemetryAndErrorHandlingSync(languageServerErrorTelemId, (context: IActionContext) => {
            // tslint:disable-next-line: strict-boolean-expressions
            context.telemetry.properties.jsonrpcMessage = message ? message.jsonrpc : "";
            context.telemetry.measurements.secondsSinceStart = (Date.now() - this._serverStartTime) / 1000;

            throw new Error(`An error occurred in the ${languageServerName}.${os.EOL}${os.EOL}${parseError(error).message}`);
        });

        return this._handler.error(error, message, count);
    }
github microsoft / vscode-azurearmtools / src / languageclient / startArmLanguageServer.ts View on Github external
function findLanguageServer(context: ExtensionContext): string {
    let serverDllPath: string;

    return callWithTelemetryAndErrorHandlingSync('findLanguageServer', (actionContext: IActionContext) => {
        actionContext.errorHandling.rethrow = true;

        let serverDllPathSetting: string | undefined = workspace.getConfiguration('armTools').get('languageServer.path');
        if (typeof serverDllPathSetting !== 'string' || serverDllPathSetting === '') {
            actionContext.telemetry.properties.customServerDllPath = 'false';

            // Default behavior: armTools.languageServer.path is not set - look for the files in their normal installed location under languageServerFolderName
            let serverFolderPath = context.asAbsolutePath(languageServerFolderName);
            serverDllPath = path.join(serverFolderPath, languageServerDllName);
            if (!fse.existsSync(serverFolderPath) || !fse.existsSync(serverDllPath)) {
                throw new Error(`Couldn't find the ARM language server at ${serverDllPath}, you may need to reinstall the extension.`);
            }
            serverDllPath = path.join(serverFolderPath, languageServerDllName);
        } else {
            actionContext.telemetry.properties.customServerDllPath = 'true';
github microsoft / vscode-azurearmtools / src / languageclient / startArmLanguageServer.ts View on Github external
function startLanguageClient(serverDllPath: string, dotnetExePath: string): void {
    callWithTelemetryAndErrorHandlingSync('startArmLanguageClient', (actionContext: IActionContext) => {
        actionContext.errorHandling.rethrow = true;

        // These trace levels are available in the server:
        //   Trace
        //   Debug
        //   Information
        //   Warning
        //   Error
        //   Critical
        //   None
        let trace: string = workspace.getConfiguration('armTools').get("languageServer.traceLevel") || defaultTraceLevel;

        let commonArgs = [
            serverDllPath,
            '--logLevel',
            trace