[forgive] Don't crash if we couldn't compile (#33001)

Compiler shouldn't crash Forgive if it can't compile (eg parse error due
to being mid-typing).

Co-authored-by: Jordan Brown <jmbrown@meta.com>
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33001).
* #33002
* __->__ #33001
* #33000

---------

Co-authored-by: Jordan Brown <jmbrown@meta.com>
This commit is contained in:
lauren 2025-04-23 21:32:11 -04:00 committed by GitHub
parent f765082996
commit b75af04670
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -134,11 +134,17 @@ documents.onDidChangeContent(async event => {
resetState();
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
const text = event.document.getText();
await compile({
text,
file: event.document.uri,
options: compilerOptions,
});
try {
await compile({
text,
file: event.document.uri,
options: compilerOptions,
});
} catch (err) {
if (err instanceof Error) {
connection.console.error(err.stack ?? '');
}
}
}
});