feat: add comprehensive error handling to LoraInfo_UTK node - 增加网络连接失败、文件读取错误等异常处理,确保程序稳定运行
This commit is contained in:
+28
-6
@@ -36,9 +36,24 @@ app.registerExtension({
|
||||
.fetchApi("/lora_info_utk", { method: "POST", body })
|
||||
.then((response) => response.json())
|
||||
.then((resp) => {
|
||||
baseModelWidget.value = resp.baseModel;
|
||||
outputWidget.value = resp.output;
|
||||
metaInfoWidget.value = resp.metaInfo;
|
||||
if (resp.error) {
|
||||
// 显示错误信息
|
||||
baseModelWidget.value = "错误";
|
||||
outputWidget.value = `获取信息失败: ${resp.error}`;
|
||||
metaInfoWidget.value = "无法获取元数据";
|
||||
} else {
|
||||
// 正常显示信息
|
||||
baseModelWidget.value = resp.baseModel;
|
||||
outputWidget.value = resp.output;
|
||||
metaInfoWidget.value = resp.metaInfo;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
// 处理网络错误
|
||||
console.error("[LoraInfo_UTK] API调用失败:", error);
|
||||
baseModelWidget.value = "网络错误";
|
||||
outputWidget.value = "无法连接到服务器,请检查网络连接";
|
||||
metaInfoWidget.value = "无法获取元数据";
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -46,9 +61,16 @@ app.registerExtension({
|
||||
const onExecuted = nodeType.prototype.onExecuted;
|
||||
nodeType.prototype.onExecuted = function (message) {
|
||||
onExecuted?.apply(this, [message]);
|
||||
this.showValueWidget.value = message.text[0];
|
||||
this.baseModelWidget.value = message.model[0];
|
||||
this.metaInfoWidget.value = message.metaInfo ? message.metaInfo[0] : "";
|
||||
try {
|
||||
this.showValueWidget.value = message.text[0];
|
||||
this.baseModelWidget.value = message.model[0];
|
||||
this.metaInfoWidget.value = message.metaInfo ? message.metaInfo[0] : "";
|
||||
} catch (error) {
|
||||
console.error("[LoraInfo_UTK] 更新界面时发生错误:", error);
|
||||
this.showValueWidget.value = "界面更新失败";
|
||||
this.baseModelWidget.value = "";
|
||||
this.metaInfoWidget.value = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user