Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions USAGE_DATA.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ vscode-java has opt-in telemetry collection, provided by [vscode-redhat-telemetr
* Information about the following settings. In the case of settings that store a well defined value (eg. path/url/string), we simply collect whether the setting has been set.
* `java.settings.url`, `java.format.settings.url`, `java.quickfix.showAt`, `java.symbols.includeSourceMethodDeclarations`, `java.completion.guessMethodArguments`, `java.completion.postfix.enabled`, `java.cleanup.actionsOnSave`, `java.sharedIndexes.enabled`, `java.inlayHints.parameterNames.enabled`, `java.server.launchMode`, `java.autobuild.enabled`
* The extension name and the choice made when a recommendation to install a 3rd party extension is proposed
* The name of Java commands being manually executed, and any resulting errors

## What's included in the general telemetry data

Expand Down
24 changes: 24 additions & 0 deletions src/errorUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// copied from https://github.com/redhat-developer/openshift-dd-ext/blob/f8c053bded9bc6c1bfac682cf4867b187e87ee76/client/src/utils/ErrorUtils.ts#L12
export function getMessage(error: any): string {
return getRawMessage(error).trim();
}

export function getRawMessage(error: any): string {
if (typeof error === 'string') {
return error;
}
if (error.stderr) {
return error.stderr;
}
if (error.message) {
return error.message;
}
if (error.error) {
return error.error;
}

// Unlikely to happen, as we're either getting an Error object with a message
// or we're dealing with a failed promise with a stderr message
// in any other case, we'll need to figure out what to return on a case by case basis
return JSON.stringify(error);
}
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { SyntaxLanguageClient } from './syntaxLanguageClient';
import { convertToGlob, deleteDirectory, ensureExists, getBuildFilePatterns, getExclusionBlob, getInclusionPatternsFromNegatedExclusion, getJavaConfig, getJavaConfiguration, hasBuildToolConflicts } from './utils';
import glob = require('glob');
import { Telemetry } from './telemetry';
import { getMessage } from './errorUtils';

const syntaxClient: SyntaxLanguageClient = new SyntaxLanguageClient();
const standardClient: StandardLanguageClient = new StandardLanguageClient();
Expand Down Expand Up @@ -291,13 +292,16 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {

const cleanWorkspaceExists = fs.existsSync(path.join(workspacePath, cleanWorkspaceFileName));
if (cleanWorkspaceExists) {
const data = {};
try {
cleanupLombokCache(context);
deleteDirectory(workspacePath);
deleteDirectory(syntaxServerWorkspacePath);
} catch (error) {
data['error'] = getMessage(error);
window.showErrorMessage(`Failed to delete ${workspacePath}: ${error}`);
}
await Telemetry.sendTelemetry(Commands.CLEAN_WORKSPACE, data);
}

// Register commands here to make it available even when the language client fails
Expand Down