扩展加载失败提示

扩展的content和precontent载入失败后会弹窗提示,显示报错信息
报错信息格式:
alert(`扩展${lib.extensions[i][0]}载入失败\ncontentError\n${decodeURI(e.stack)}`);
This commit is contained in:
keyframes 2024-02-15 14:59:22 +08:00
parent a2b39a09d2
commit 7a2643986b
2 changed files with 15 additions and 5 deletions

View File

@ -1880,11 +1880,17 @@ export class Game extends Uninstantable {
help: help, help: help,
config: objectConfig config: objectConfig
} }
if (precontent) { try{
_status.extension = name; if (precontent) {
await (gnc.is.generatorFunc(precontent) ? gnc.of(precontent) : precontent).call(object, config); _status.extension = name;
delete _status.extension;
await (gnc.is.generatorFunc(precontent) ? gnc.of(precontent) : precontent).call(object, config);
delete _status.extension;
}
}catch(e1){
alert(`扩展${name}载入失败\nprecontentError\n${decodeURI(e1.stack)}`);
} }
if (content) lib.extensions.push([name, content, config, _status.evaluatingExtension, objectPackage || {}]); if (content) lib.extensions.push([name, content, config, _status.evaluatingExtension, objectPackage || {}]);
} }
catch (e) { catch (e) {

View File

@ -587,7 +587,11 @@ export async function onload(resetGameTimeout) {
_status.extension = lib.extensions[i][0]; _status.extension = lib.extensions[i][0];
_status.evaluatingExtension = lib.extensions[i][3]; _status.evaluatingExtension = lib.extensions[i][3];
if (typeof lib.extensions[i][1] == "function") if (typeof lib.extensions[i][1] == "function")
await (gnc.is.coroutine(lib.extensions[i][1]) ? gnc.of(lib.extensions[i][1]) : lib.extensions[i][1]).call(lib.extensions[i], lib.extensions[i][2], lib.extensions[i][4]); try{
await (gnc.is.coroutine(lib.extensions[i][1]) ? gnc.of(lib.extensions[i][1]) : lib.extensions[i][1]).call(lib.extensions[i], lib.extensions[i][2], lib.extensions[i][4]);
}catch(e){
alert(`扩展${lib.extensions[i][0]}载入失败\ncontentError\n${decodeURI(e.stack)}`);
}
if (lib.extensions[i][4]) { if (lib.extensions[i][4]) {
if (lib.extensions[i][4].character) { if (lib.extensions[i][4].character) {
for (var j in lib.extensions[i][4].character.character) { for (var j in lib.extensions[i][4].character.character) {