summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-04-16 20:23:03 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-16 20:23:03 +0200
commit72df9c741746a16125a46b6e2be567c45925911e (patch)
tree7a89f85f1022e68a1c42f6cd95032a188d4ab2ac /Libraries
parent2db2b8b0efa519741ab52a0423ea5b67dd22abd6 (diff)
downloadserenity-72df9c741746a16125a46b6e2be567c45925911e.zip
LibJS: Dump a JavaScript backtrace when throwing exceptions
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibJS/Interpreter.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibJS/Interpreter.cpp b/Libraries/LibJS/Interpreter.cpp
index 06362bc173..48820e9f10 100644
--- a/Libraries/LibJS/Interpreter.cpp
+++ b/Libraries/LibJS/Interpreter.cpp
@@ -219,6 +219,13 @@ Value Interpreter::throw_exception(Exception* exception)
if (exception->value().is_object() && exception->value().as_object().is_error()) {
auto& error = static_cast<Error&>(exception->value().as_object());
dbg() << "Throwing JavaScript Error: " << error.name() << ", " << error.message();
+
+ for (ssize_t i = m_call_stack.size() - 1; i >= 0; --i) {
+ auto function_name = m_call_stack[i].function_name;
+ if (function_name.is_empty())
+ function_name = "<anonymous>";
+ dbg() << " " << function_name;
+ }
}
m_exception = exception;
unwind(ScopeType::Try);