@@ -6,7 +6,7 @@ import * as os from "os";
6
6
import * as path from "path" ;
7
7
import * as vscode from "vscode" ;
8
8
9
- import { instrumentOperation , sendInfo } from "vscode-extension-telemetry-wrapper" ;
9
+ import { instrumentOperation , sendError , sendInfo , setUserError } from "vscode-extension-telemetry-wrapper" ;
10
10
import * as anchor from "./anchor" ;
11
11
import { buildWorkspace } from "./build" ;
12
12
import { populateStepFilters , substituteFilterVariables } from "./classFilter" ;
@@ -539,16 +539,43 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
539
539
}
540
540
}
541
541
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
+
542
557
private async fixMainClass ( folder : vscode . Uri | undefined , config : vscode . DebugConfiguration ,
543
558
validationResponse : lsPlugin . ILaunchValidationResponse , progressReporter : IProgressReporter ) :
544
559
Promise < lsPlugin . IMainClassOption | undefined > {
545
560
const errors : string [ ] = [ ] ;
546
561
if ( ! validationResponse . mainClass . isValid ) {
547
562
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 ) ;
548
569
}
549
570
550
571
if ( ! validationResponse . projectName . isValid ) {
551
572
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 ) ;
552
579
}
553
580
554
581
if ( validationResponse . proposals && validationResponse . proposals . length ) {
@@ -557,14 +584,15 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
557
584
message : errors . join ( os . EOL ) ,
558
585
type : Type . USAGEERROR ,
559
586
anchor : anchor . FAILED_TO_RESOLVE_CLASSPATH ,
587
+ bypassLog : true , // Avoid logging the raw user input in the logger for privacy.
560
588
} , "Fix" ) ;
561
589
if ( answer === "Fix" ) {
562
590
const selectedFix = await mainClassPicker . showQuickPick ( validationResponse . proposals ,
563
591
"Please select main class<project name>." , false ) ;
564
592
if ( selectedFix ) {
565
593
sendInfo ( "" , {
566
594
fix : "yes" ,
567
- fixMessage : errors . join ( os . EOL ) ,
595
+ fixMessage : "Fix the configs of mainClass and projectName" ,
568
596
} ) ;
569
597
await this . persistMainClassOption ( folder , config , selectedFix ) ;
570
598
}
@@ -579,6 +607,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
579
607
message : errors . join ( os . EOL ) ,
580
608
type : Type . USAGEERROR ,
581
609
anchor : anchor . FAILED_TO_RESOLVE_CLASSPATH ,
610
+ bypassLog : true , // Avoid logging the raw user input in the logger for privacy.
582
611
} ) ;
583
612
}
584
613
0 commit comments