Skip to content

Commit 12ecccd

Browse files
committed
Don't throw for unhandled messages
1 parent 7c0b92c commit 12ecccd

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/perseus-editor/src/iframe-content-renderer.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* to get the data to render. When the iframe is loaded, it's javascript sends
1010
* a message to the parent, which triggers the parent to send the current data.
1111
*/
12-
import {UnreachableCaseError} from "@khanacademy/wonder-stuff-core";
1312
import * as React from "react";
1413

1514
import {
@@ -24,6 +23,12 @@ let nextIframeID = 0;
2423
const requestIframeData: Record<string, any> = {};
2524
const updateIframeHeight: Record<string, any> = {};
2625

26+
/**
27+
* Processes a message sent to the iframe parent (ie. this component).
28+
*
29+
* Note that this handler also sees messages sent from itself to the iframe so
30+
* we intentionally ignore those here.
31+
*/
2732
function processIframeParentMessage(message: MessageToIFrameParent) {
2833
if (!isPerseusMessage(message)) {
2934
return;
@@ -45,7 +50,12 @@ function processIframeParentMessage(message: MessageToIFrameParent) {
4550
return;
4651

4752
default:
48-
throw new UnreachableCaseError(messageType);
53+
// This is a type assertion that ensures we handle all of the types
54+
// of messages we handle. We do _not_ throw an UnreachableCaseError
55+
// here because this handler also sees messages sent from this
56+
// component and those are not currently filtered by
57+
// isPerseusMessage().
58+
const _: never = messageType;
4959
}
5060
}
5161

0 commit comments

Comments
 (0)