Prevent errors during rendering from flooding the log
This commit is contained in:
parent
0715abdf74
commit
6eef61c5c7
21
src/main.js
21
src/main.js
|
|
@ -85,10 +85,12 @@ window.addEventListener('unhandledrejection', (event) => {
|
||||||
|
|
||||||
function forwardConsole(fnName, dest) {
|
function forwardConsole(fnName, dest) {
|
||||||
const original = console[fnName];
|
const original = console[fnName];
|
||||||
console[fnName] = (message) => {
|
console[fnName] = (...args) => {
|
||||||
const error = new Error();
|
const error = new Error();
|
||||||
const stackLines = error.stack.split("\n");
|
const stackLines = error.stack.split("\n");
|
||||||
|
|
||||||
|
let message = args.join(" "); // Join all arguments into a single string
|
||||||
|
|
||||||
if (fnName === "error") {
|
if (fnName === "error") {
|
||||||
// Send the full stack trace for errors
|
// Send the full stack trace for errors
|
||||||
invoke(dest, { msg: `${message}\nStack trace:\n${stackLines.slice(1).join("\n")}` });
|
invoke(dest, { msg: `${message}\nStack trace:\n${stackLines.slice(1).join("\n")}` });
|
||||||
|
|
@ -98,7 +100,7 @@ function forwardConsole(fnName, dest) {
|
||||||
invoke(dest, { msg: `${location ? location[0] : 'unknown'}: ${message}` });
|
invoke(dest, { msg: `${location ? location[0] : 'unknown'}: ${message}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
original(message);
|
original(...args); // Pass all arguments to the original console method
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,6 +161,8 @@ let layersDirty = false;
|
||||||
let menuDirty = false;
|
let menuDirty = false;
|
||||||
let outlinerDirty = false;
|
let outlinerDirty = false;
|
||||||
let infopanelDirty = false;
|
let infopanelDirty = false;
|
||||||
|
let lastErrorMessage = null; // To keep track of the last error
|
||||||
|
let repeatCount = 0;
|
||||||
|
|
||||||
let clipboard = [];
|
let clipboard = [];
|
||||||
|
|
||||||
|
|
@ -7247,7 +7251,18 @@ function renderAll() {
|
||||||
infopanelDirty = false;
|
infopanelDirty = false;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error during rendering:", error);
|
const errorMessage = error.message || error.toString(); // Use error message or string representation of the error
|
||||||
|
|
||||||
|
if (errorMessage !== lastErrorMessage) {
|
||||||
|
// A new error, log it and reset repeat count
|
||||||
|
console.error("Error during rendering:", errorMessage);
|
||||||
|
lastErrorMessage = errorMessage;
|
||||||
|
repeatCount = 1;
|
||||||
|
} else if (repeatCount === 1) {
|
||||||
|
// The error repeats for the second time, log "[Repeats]"
|
||||||
|
console.warn("[Repeats]");
|
||||||
|
repeatCount = 2;
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
requestAnimationFrame(renderAll);
|
requestAnimationFrame(renderAll);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue