fix: not throw.

This commit is contained in:
Rintim 2024-01-06 01:38:56 +08:00
parent 7ae7deb1f4
commit e24b14b676
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
1 changed files with 4 additions and 8 deletions

View File

@ -33,13 +33,9 @@ export const importMode = generateImportFunction('mode', (name) => `../../mode/$
*/
function generateImportFunction(type, pathParser) {
return async (name) => {
try {
const modeContent = await import(pathParser(name));
if (!modeContent.type) return;
if (modeContent.type !== type) throw new Error(`Loaded Content doesn't conform to "${type}" but "${modeContent.type}".`);
await game.import(type, modeContent.default);
} catch (e) {
console.error(e);
}
const modeContent = await import(pathParser(name));
if (!modeContent.type) return;
if (modeContent.type !== type) throw new Error(`Loaded Content doesn't conform to "${type}" but "${modeContent.type}".`);
await game.import(type, modeContent.default);
}
}