From b00963ffde2e27dea41c311b2b01f7cae5f799be Mon Sep 17 00:00:00 2001 From: mofeiZ <34200447+mofeiZ@users.noreply.github.com> Date: Wed, 25 Jan 2023 11:23:09 -0500 Subject: [PATCH] [playground] Handle invariant violation errors playground currently hard crashes when we hit an invariant violation image [playground link](https://0xeac7-forget.vercel.app/#eyJzb3VyY2UiOiJcbmZ1bmN0aW9uIHVzZUJhcihwcm9wcykge1xuICBwcm9wcyA9IG51bGw7XG4gIGxldCB5LCB6O1xuXG4gIGlmIChwcm9wcy54KSB7XG4gICAgbGV0IHkgPSB1c2VGb28ocHJvcHMuYS5iKTtcbiAgICB3aGlsZSAoYmFyKCkpIHtcbiAgICAgIGlmIChwcm9wcy55KSB7XG4gICAgICAgIHogPSBiYXooKTtcbiAgICAgIH1cbiAgICB9XG4gIH1cblxuICByZXR1cm4gW3ksIHpdXG59In0=) This should fix that --- .../forget/packages/playground/components/Editor/index.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/forget/packages/playground/components/Editor/index.tsx b/compiler/forget/packages/playground/components/Editor/index.tsx index 26837ed606..9cea6e046a 100644 --- a/compiler/forget/packages/playground/components/Editor/index.tsx +++ b/compiler/forget/packages/playground/components/Editor/index.tsx @@ -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 }; } }