Skip to content

Commit affa56d

Browse files
committed
Error when require attributes are not set
These are required for scratch to work and should always be set.
1 parent ce329b3 commit affa56d

1 file changed

Lines changed: 25 additions & 19 deletions

File tree

src/scratch.jsx

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,28 @@ const handleSavingSucceeded = () => {
4949
window.top.postMessage({ type: "scratch-gui-saving-succeeded" }, "*");
5050
};
5151

52-
const root = createRoot(appTarget);
53-
root.render(
54-
<>
55-
<style>{ScratchStyles}</style>
56-
<WrappedGui
57-
projectId={projectId}
58-
locale={locale}
59-
menuBarHidden={true}
60-
projectHost={`${apiUrl}/api/scratch/projects`}
61-
assetHost={`${apiUrl}/api/scratch/assets`}
62-
basePath={`${process.env.ASSETS_URL}/scratch-gui/`}
63-
onUpdateProjectId={handleUpdateProjectId}
64-
onShowCreatingRemixAlert={handleRemixingStarted}
65-
onShowRemixSuccessAlert={handleRemixingSucceeded}
66-
onShowSavingAlert={handleSavingStarted}
67-
onShowSaveSuccessAlert={handleSavingSucceeded}
68-
/>
69-
</>,
70-
);
52+
if (!projectId) {
53+
console.error("project_id is required but not set");
54+
} else if (!apiUrl) {
55+
console.error("api_url is required but not set");
56+
} else {
57+
const root = createRoot(appTarget);
58+
root.render(
59+
<>
60+
<style>{ScratchStyles}</style>
61+
<WrappedGui
62+
projectId={projectId}
63+
locale={locale}
64+
menuBarHidden={true}
65+
projectHost={`${apiUrl}/api/scratch/projects`}
66+
assetHost={`${apiUrl}/api/scratch/assets`}
67+
basePath={`${process.env.ASSETS_URL}/scratch-gui/`}
68+
onUpdateProjectId={handleUpdateProjectId}
69+
onShowCreatingRemixAlert={handleRemixingStarted}
70+
onShowRemixSuccessAlert={handleRemixingSucceeded}
71+
onShowSavingAlert={handleSavingStarted}
72+
onShowSaveSuccessAlert={handleSavingSucceeded}
73+
/>
74+
</>,
75+
);
76+
}

0 commit comments

Comments
 (0)