diff --git a/tools/respecDocWriter.js b/tools/respecDocWriter.js index 0f4dae4f1e..3da3da07bd 100644 --- a/tools/respecDocWriter.js +++ b/tools/respecDocWriter.js @@ -309,6 +309,16 @@ function handleConsoleMessages(page, onError, onWarning) { if (typeof obj === "string") { // Old ReSpec versions might report errors as strings. return JSON.stringify({ message: String(obj) }); + } else if (obj instanceof Error && !obj.plugin) { + return JSON.stringify({ + message: obj.message, + plugin: "unknown", + name: obj.name, + stack: obj.stack?.replace( + obj.message, + `${obj.message.slice(0, 30)}…` + ), + }); } else { // Ideally: `obj instanceof RsError` and `RsError instanceof Error`. return JSON.stringify(obj); @@ -335,6 +345,7 @@ function handleConsoleMessages(page, onError, onWarning) { switch (type) { case "error": return onError(JSON.parse(text)); + case "warn": case "warning": return onWarning(JSON.parse(text)); }