From 16d7e89c7d3368791560515c8771be9bfce652fd Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Tue, 14 Apr 2020 15:22:51 -0300 Subject: [PATCH] Set to show the JavaScript exception message and stacktrace, when a exception is throw, showing the function and lines from where the exception/error is coming from. https://stackoverflow.com/questions/591857/how-can-i-get-a-javascript-stack-trace-when-i-throw-an-exception Exception example: Invalid HTML on card: Error: The media element is missing its 'src' attribute. at http://127.0.0.1:50233/_anki/reviewer.js:246:23 at http://127.0.0.1:50233/_anki/reviewer.js:112:9 at Array.forEach () at setAnkiMedia (http://127.0.0.1:50233/_anki/reviewer.js:111:11) at AnkiMediaQueue.setup (http://127.0.0.1:50233/_anki/reviewer.js:244:9) at eval (eval at (http://127.0.0.1:50233/_anki/jquery.js:2:2651), :2:11) at eval () at http://127.0.0.1:50233/_anki/jquery.js:2:2651 at Function.globalEval (http://127.0.0.1:50233/_anki/jquery.js:2:2662) at Ha (http://127.0.0.1:50233/_anki/jquery.js:3:21262) --- qt/ts/src/reviewer.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qt/ts/src/reviewer.ts b/qt/ts/src/reviewer.ts index 130ff09f6..bf27039c9 100644 --- a/qt/ts/src/reviewer.ts +++ b/qt/ts/src/reviewer.ts @@ -39,7 +39,11 @@ function _updateQA(html, fadeTime, onupdate, onshown) { try { qa.html(html); } catch (err) { - qa.text("Invalid HTML on card: " + err); + qa.html( + "Invalid HTML on card: " + + err + + ("\n" + err.stack).replace(/\n/g, "
") + ); } _runHook(onUpdateHook);