Skip to content

Commit

Permalink
Fixed BADCLIENT error message (#60925)
Browse files Browse the repository at this point in the history
Co-authored-by: Armando Aguirre Sepulveda <[email protected]>
  • Loading branch information
armanio123 and Armando Aguirre Sepulveda authored Jan 7, 2025
1 parent a5196c7 commit 717d05c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3058,20 +3058,21 @@ export class Session<TMessage = string> implements EventSender {
codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, this.getFormatOptions(file), this.getPreferences(file));
}
catch (e) {
const error = e instanceof Error ? e : new Error(e);

const ls = project.getLanguageService();
const existingDiagCodes = [
...ls.getSyntacticDiagnostics(file),
...ls.getSemanticDiagnostics(file),
...ls.getSuggestionDiagnostics(file),
].map(d =>
decodedTextSpanIntersectsWith(startPosition, endPosition - startPosition, d.start!, d.length!)
&& d.code
);
]
.filter(d => decodedTextSpanIntersectsWith(startPosition, endPosition - startPosition, d.start!, d.length!))
.map(d => d.code);
const badCode = args.errorCodes.find(c => !existingDiagCodes.includes(c));
if (badCode !== undefined) {
e.message = `BADCLIENT: Bad error code, ${badCode} not found in range ${startPosition}..${endPosition} (found: ${existingDiagCodes.join(", ")}); could have caused this error:\n${e.message}`;
error.message += `\nAdditional information: BADCLIENT: Bad error code, ${badCode} not found in range ${startPosition}..${endPosition} (found: ${existingDiagCodes.join(", ")})`;
}
throw e;
throw error;
}
return simplifiedResult ? codeActions.map(codeAction => this.mapCodeFixAction(codeAction)) : codeActions;
}
Expand Down

0 comments on commit 717d05c

Please sign in to comment.