@@ -6,7 +6,7 @@ import * as os from "os";
66import * as path from "path" ;
77import * as vscode from "vscode" ;
88
9- import { instrumentOperation , sendInfo } from "vscode-extension-telemetry-wrapper" ;
9+ import { instrumentOperation , sendError , sendInfo , setUserError } from "vscode-extension-telemetry-wrapper" ;
1010import * as anchor from "./anchor" ;
1111import { buildWorkspace } from "./build" ;
1212import { populateStepFilters , substituteFilterVariables } from "./classFilter" ;
@@ -539,16 +539,43 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
539539 }
540540 }
541541
542+ private getValidationErrorMessage ( error : lsPlugin . IValidationResult ) : string {
543+ switch ( error . kind ) {
544+ case lsPlugin . CONFIGERROR_INVALID_CLASS_NAME :
545+ return "ConfigError: mainClass was configured with an invalid class name." ;
546+ case lsPlugin . CONFIGERROR_MAIN_CLASS_NOT_EXIST :
547+ return "ConfigError: mainClass does not exist." ;
548+ case lsPlugin . CONFIGERROR_MAIN_CLASS_NOT_UNIQUE :
549+ return "ConfigError: mainClass is not unique in the workspace" ;
550+ case lsPlugin . CONFIGERROR_INVALID_JAVA_PROJECT :
551+ return "ConfigError: could not find a Java project with the configured projectName." ;
552+ }
553+
554+ return "ConfigError: Invalid mainClass/projectName configs." ;
555+ }
556+
542557 private async fixMainClass ( folder : vscode . Uri | undefined , config : vscode . DebugConfiguration ,
543558 validationResponse : lsPlugin . ILaunchValidationResponse , progressReporter : IProgressReporter ) :
544559 Promise < lsPlugin . IMainClassOption | undefined > {
545560 const errors : string [ ] = [ ] ;
546561 if ( ! validationResponse . mainClass . isValid ) {
547562 errors . push ( String ( validationResponse . mainClass . message ) ) ;
563+ const errorLog : Error = {
564+ name : "error" ,
565+ message : this . getValidationErrorMessage ( validationResponse . mainClass ) ,
566+ } ;
567+ setUserError ( errorLog ) ;
568+ sendError ( errorLog ) ;
548569 }
549570
550571 if ( ! validationResponse . projectName . isValid ) {
551572 errors . push ( String ( validationResponse . projectName . message ) ) ;
573+ const errorLog : Error = {
574+ name : "error" ,
575+ message : this . getValidationErrorMessage ( validationResponse . projectName ) ,
576+ } ;
577+ setUserError ( errorLog ) ;
578+ sendError ( errorLog ) ;
552579 }
553580
554581 if ( validationResponse . proposals && validationResponse . proposals . length ) {
@@ -557,14 +584,15 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
557584 message : errors . join ( os . EOL ) ,
558585 type : Type . USAGEERROR ,
559586 anchor : anchor . FAILED_TO_RESOLVE_CLASSPATH ,
587+ bypassLog : true , // Avoid logging the raw user input in the logger for privacy.
560588 } , "Fix" ) ;
561589 if ( answer === "Fix" ) {
562590 const selectedFix = await mainClassPicker . showQuickPick ( validationResponse . proposals ,
563591 "Please select main class<project name>." , false ) ;
564592 if ( selectedFix ) {
565593 sendInfo ( "" , {
566594 fix : "yes" ,
567- fixMessage : errors . join ( os . EOL ) ,
595+ fixMessage : "Fix the configs of mainClass and projectName" ,
568596 } ) ;
569597 await this . persistMainClassOption ( folder , config , selectedFix ) ;
570598 }
@@ -579,6 +607,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
579607 message : errors . join ( os . EOL ) ,
580608 type : Type . USAGEERROR ,
581609 anchor : anchor . FAILED_TO_RESOLVE_CLASSPATH ,
610+ bypassLog : true , // Avoid logging the raw user input in the logger for privacy.
582611 } ) ;
583612 }
584613
0 commit comments