Improve error UI

This commit is contained in:
pythongosssss 2023-04-08 16:37:09 +01:00
parent 12f9bfe895
commit b78ebfcf9d

View File

@ -872,12 +872,21 @@ class ComfyApp {
try { try {
this.graph.configure(graphData); this.graph.configure(graphData);
} catch (error) { } catch (error) {
let errorHint = ""; let errorHint = [];
// Try extracting filename to see if it was caused by an extension script // Try extracting filename to see if it was caused by an extension script
const filename = error.fileName || (error.stack || "").match(/(\/extensions\/.*\.js)/)?.[1]; const filename = error.fileName || (error.stack || "").match(/(\/extensions\/.*\.js)/)?.[1];
const pos = (filename || "").indexOf("/extensions/"); const pos = (filename || "").indexOf("/extensions/");
if (pos > -1) { if (pos > -1) {
errorHint = "This may be due to the following script: " + filename.substring(pos + 12); errorHint.push(
$el("span", { textContent: "This may be due to the following script:" }),
$el("br"),
$el("span", {
style: {
fontWeight: "bold",
},
textContent: filename.substring(pos),
})
);
} }
// Show dialog to let the user know something went wrong loading the data // Show dialog to let the user know something went wrong loading the data
@ -895,11 +904,11 @@ class ComfyApp {
fontSize: "10px", fontSize: "10px",
maxHeight: "50vh", maxHeight: "50vh",
overflow: "auto", overflow: "auto",
backgroundColor: "rgba(255,0,0,0.2)", backgroundColor: "rgba(0,0,0,0.2)",
}, },
textContent: error.stack || "No stacktrace available", textContent: error.stack || "No stacktrace available",
}), }),
$el("span", { textContent: errorHint, style: { fontWeight: "bold" } }), ...errorHint,
]).outerHTML ]).outerHTML
); );