wasm: print error message on missing preload file

We would previously try to json-parse the 404 error
message and then abort with an json parse error.

Throw a custom error instead.

Change-Id: I7240294b2b107cd758f22187ae6f2b1d6923fdd7
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
(cherry picked from commit ce62b60d8590f707a0d011e6b95f1f7c729ba4e1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Morten Sørvig 2024-05-15 22:30:37 +02:00 committed by Qt Cherry-pick Bot
parent 838a2fde28
commit 61ad998226

View File

@ -121,8 +121,13 @@ async function qtLoad(config)
}
}
}
const fetchJsonHelper = async path => (await fetch(path)).json();
const filesToPreload = (await Promise.all(config.qt.preload.map(fetchJsonHelper))).flat();
const preloadFetchHelper = async (path) => {
const response = await fetch(path);
if (!response.ok)
throw new Error("Could not fetch preload file: " + path);
return response.json();
}
const filesToPreload = (await Promise.all(config.qt.preload.map(preloadFetchHelper))).flat();
const qtPreRun = (instance) => {
// Copy qt.environment to instance.ENV
throwIfEnvUsedButNotExported(instance, config);