Improve logging of prettier errors (#32665)

In particular, seems like the error message and the message sent to
prettier were mixed up before

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-06-13 01:26:06 -06:00 committed by GitHub
parent bc68455320
commit 83cd1d2545
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 8 deletions

View file

@ -52,18 +52,17 @@ async function handleBuffer(prettier) {
try {
message = JSON.parse(messageText);
} catch (e) {
sendResponse(makeError(`Failed to parse message '${messageText}': ${e}`));
sendResponse(makeError(`Parse error in request message: ${e}\nMessage: ${messageText}`));
continue;
}
// allow concurrent request handling by not `await`ing the message handling promise (async function)
handleMessage(message, prettier).catch((e) => {
const errorMessage = message;
if ((errorMessage.params || {}).text !== undefined) {
errorMessage.params.text = "..snip..";
if ((message.params || {}).text !== undefined) {
message.params.text = "..snip..";
}
sendResponse({
id: message.id,
...makeError(`error during message '${JSON.stringify(errorMessage)}' handling: ${e}`),
...makeError(`${e}\nWhile handling prettier request: ${JSON.stringify(message)}`),
});
});
}