LibJS: Dump a JavaScript backtrace when throwing exceptions

This commit is contained in:
Andreas Kling 2020-04-16 20:23:03 +02:00
parent 2db2b8b0ef
commit 72df9c7417
Notes: sideshowbarker 2024-07-19 07:32:31 +09:00

View file

@ -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);