mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[playground] Handle invariant violation errors
playground currently hard crashes when we hit an invariant violation <img width="1104" alt="image" src="https://user-images.githubusercontent.com/34200447/214615036-dbe307d8-132d-4186-a8ab-6fcaf69801d1.png"> [playground link](https://0xeac7-forget.vercel.app/#eyJzb3VyY2UiOiJcbmZ1bmN0aW9uIHVzZUJhcihwcm9wcykge1xuICBwcm9wcyA9IG51bGw7XG4gIGxldCB5LCB6O1xuXG4gIGlmIChwcm9wcy54KSB7XG4gICAgbGV0IHkgPSB1c2VGb28ocHJvcHMuYS5iKTtcbiAgICB3aGlsZSAoYmFyKCkpIHtcbiAgICAgIGlmIChwcm9wcy55KSB7XG4gICAgICAgIHogPSBiYXooKTtcbiAgICAgIH1cbiAgICB9XG4gIH1cblxuICByZXR1cm4gW3ksIHpdXG59In0=) This should fix that
This commit is contained in:
@@ -67,6 +67,11 @@ function compile(source: string): CompilerOutput {
|
||||
return { kind: "ok", results };
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
// error might be an invariant violation or other runtime error
|
||||
// (i.e. object shape that is not CompilerError)
|
||||
if (error.details == null) {
|
||||
error.details = [];
|
||||
}
|
||||
return { kind: "err", error };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user