Skip to content

Commit 717d05c

Browse files
Armando AguirreArmando Aguirre Sepulveda
Armando Aguirre
and
Armando Aguirre Sepulveda
authored
Fixed BADCLIENT error message (microsoft#60925)
Co-authored-by: Armando Aguirre Sepulveda <[email protected]>
1 parent a5196c7 commit 717d05c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/server/session.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -3058,20 +3058,21 @@ export class Session<TMessage = string> implements EventSender {
30583058
codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, this.getFormatOptions(file), this.getPreferences(file));
30593059
}
30603060
catch (e) {
3061+
const error = e instanceof Error ? e : new Error(e);
3062+
30613063
const ls = project.getLanguageService();
30623064
const existingDiagCodes = [
30633065
...ls.getSyntacticDiagnostics(file),
30643066
...ls.getSemanticDiagnostics(file),
30653067
...ls.getSuggestionDiagnostics(file),
3066-
].map(d =>
3067-
decodedTextSpanIntersectsWith(startPosition, endPosition - startPosition, d.start!, d.length!)
3068-
&& d.code
3069-
);
3068+
]
3069+
.filter(d => decodedTextSpanIntersectsWith(startPosition, endPosition - startPosition, d.start!, d.length!))
3070+
.map(d => d.code);
30703071
const badCode = args.errorCodes.find(c => !existingDiagCodes.includes(c));
30713072
if (badCode !== undefined) {
3072-
e.message = `BADCLIENT: Bad error code, ${badCode} not found in range ${startPosition}..${endPosition} (found: ${existingDiagCodes.join(", ")}); could have caused this error:\n${e.message}`;
3073+
error.message += `\nAdditional information: BADCLIENT: Bad error code, ${badCode} not found in range ${startPosition}..${endPosition} (found: ${existingDiagCodes.join(", ")})`;
30733074
}
3074-
throw e;
3075+
throw error;
30753076
}
30763077
return simplifiedResult ? codeActions.map(codeAction => this.mapCodeFixAction(codeAction)) : codeActions;
30773078
}

0 commit comments

Comments
 (0)